2019-07-07 11:18:12 +05:30
|
|
|
/* eslint-disable import/no-commonjs, filenames/match-regex */
|
|
|
|
|
2019-05-05 18:10:48 +05:30
|
|
|
const BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV || null;
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
let presets = [
|
2019-05-05 18:10:48 +05:30
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
2020-03-13 15:44:24 +05:30
|
|
|
useBuiltIns: 'usage',
|
|
|
|
corejs: { version: 3, proposals: true },
|
2019-05-05 18:10:48 +05:30
|
|
|
modules: false,
|
2020-10-24 23:57:45 +05:30
|
|
|
/**
|
|
|
|
* This list of browsers is a conservative first definition, based on
|
|
|
|
* https://docs.gitlab.com/ee/install/requirements.html#supported-web-browsers
|
|
|
|
* with the following reasoning:
|
|
|
|
*
|
|
|
|
* - Edge: Pick the last two major version before the Chrome switch
|
|
|
|
* - Rest: We should support the latest ESR of Firefox: 68, because it used quite a lot.
|
|
|
|
* For the rest, pick browser versions that have a similar age to Firefox 68.
|
|
|
|
*
|
|
|
|
* See also this follow-up epic:
|
|
|
|
* https://gitlab.com/groups/gitlab-org/-/epics/3957
|
|
|
|
*/
|
2019-05-05 18:10:48 +05:30
|
|
|
targets: {
|
2020-10-24 23:57:45 +05:30
|
|
|
chrome: '73',
|
|
|
|
edge: '17',
|
|
|
|
firefox: '68',
|
|
|
|
safari: '12',
|
2019-05-05 18:10:48 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// include stage 3 proposals
|
|
|
|
const plugins = [
|
|
|
|
'@babel/plugin-syntax-import-meta',
|
|
|
|
'@babel/plugin-proposal-class-properties',
|
|
|
|
'@babel/plugin-proposal-json-strings',
|
|
|
|
'@babel/plugin-proposal-private-methods',
|
2020-10-24 23:57:45 +05:30
|
|
|
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/229146
|
|
|
|
'@babel/plugin-transform-arrow-functions',
|
2020-03-13 15:44:24 +05:30
|
|
|
'lodash',
|
2019-05-05 18:10:48 +05:30
|
|
|
];
|
|
|
|
|
|
|
|
// add code coverage tooling if necessary
|
|
|
|
if (BABEL_ENV === 'coverage') {
|
|
|
|
plugins.push([
|
|
|
|
'babel-plugin-istanbul',
|
|
|
|
{
|
|
|
|
exclude: ['spec/javascripts/**/*', 'app/assets/javascripts/locale/**/app.js'],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
// Jest is running in node environment, so we need additional plugins
|
2019-09-04 21:01:54 +05:30
|
|
|
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
2019-07-31 22:56:46 +05:30
|
|
|
if (isJest) {
|
2019-07-07 11:18:12 +05:30
|
|
|
plugins.push('@babel/plugin-transform-modules-commonjs');
|
|
|
|
/*
|
|
|
|
without the following, babel-plugin-istanbul throws an error:
|
2019-12-21 20:55:43 +05:30
|
|
|
https://gitlab.com/gitlab-org/gitlab-foss/issues/58390
|
2019-07-07 11:18:12 +05:30
|
|
|
*/
|
|
|
|
plugins.push('babel-plugin-dynamic-import-node');
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
presets = [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
targets: {
|
|
|
|
node: 'current',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
2019-05-05 18:10:48 +05:30
|
|
|
}
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
module.exports = { presets, plugins, sourceType: 'unambiguous' };
|