2018-10-02 17:11:53 -04:00
|
|
|
const BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV || null;
|
|
|
|
|
2020-05-27 08:08:19 -04:00
|
|
|
let presets = [
|
2018-10-02 17:11:53 -04:00
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
2020-02-05 16:09:02 -05:00
|
|
|
useBuiltIns: 'usage',
|
|
|
|
corejs: { version: 3, proposals: true },
|
2018-10-02 17:11:53 -04:00
|
|
|
modules: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// include stage 3 proposals
|
|
|
|
const plugins = [
|
|
|
|
'@babel/plugin-syntax-import-meta',
|
|
|
|
'@babel/plugin-proposal-class-properties',
|
|
|
|
'@babel/plugin-proposal-json-strings',
|
2019-01-09 01:20:56 -05:00
|
|
|
'@babel/plugin-proposal-private-methods',
|
2020-08-10 11:09:49 -04:00
|
|
|
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/229146
|
|
|
|
'@babel/plugin-transform-arrow-functions',
|
2020-01-21 19:08:47 -05:00
|
|
|
'lodash',
|
2018-10-02 17:11:53 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
// 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-04-25 09:38:15 -04:00
|
|
|
// Jest is running in node environment, so we need additional plugins
|
2019-06-03 18:51:02 -04:00
|
|
|
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
2019-04-25 09:38:15 -04:00
|
|
|
if (isJest) {
|
2019-02-28 06:34:47 -05:00
|
|
|
plugins.push('@babel/plugin-transform-modules-commonjs');
|
2019-03-05 04:07:16 -05:00
|
|
|
/*
|
|
|
|
without the following, babel-plugin-istanbul throws an error:
|
2019-09-26 08:06:00 -04:00
|
|
|
https://gitlab.com/gitlab-org/gitlab-foss/issues/58390
|
2019-03-05 04:07:16 -05:00
|
|
|
*/
|
|
|
|
plugins.push('babel-plugin-dynamic-import-node');
|
2020-05-27 08:08:19 -04:00
|
|
|
|
|
|
|
presets = [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
targets: {
|
|
|
|
node: 'current',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
2018-08-29 16:45:53 -04:00
|
|
|
}
|
|
|
|
|
2020-02-05 16:09:02 -05:00
|
|
|
module.exports = { presets, plugins, sourceType: 'unambiguous' };
|