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;
|
|
|
|
|
|
|
|
const presets = [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
modules: false,
|
|
|
|
targets: {
|
|
|
|
ie: '11',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// include stage 3 proposals
|
|
|
|
const plugins = [
|
|
|
|
'@babel/plugin-syntax-dynamic-import',
|
|
|
|
'@babel/plugin-syntax-import-meta',
|
|
|
|
'@babel/plugin-proposal-class-properties',
|
|
|
|
'@babel/plugin-proposal-json-strings',
|
|
|
|
'@babel/plugin-proposal-private-methods',
|
|
|
|
];
|
|
|
|
|
|
|
|
// add code coverage tooling if necessary
|
|
|
|
if (BABEL_ENV === 'coverage') {
|
|
|
|
plugins.push([
|
|
|
|
'babel-plugin-istanbul',
|
|
|
|
{
|
|
|
|
exclude: ['spec/javascripts/**/*', 'app/assets/javascripts/locale/**/app.js'],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// add rewire support when running tests
|
|
|
|
if (BABEL_ENV === 'karma' || BABEL_ENV === 'coverage') {
|
|
|
|
plugins.push('babel-plugin-rewire');
|
|
|
|
}
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
// Jest is running in node environment, so we need additional plugins
|
|
|
|
const isJest = !!process.env.JEST_WORKER_ID;
|
|
|
|
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:
|
|
|
|
https://gitlab.com/gitlab-org/gitlab-ce/issues/58390
|
|
|
|
*/
|
|
|
|
plugins.push('babel-plugin-dynamic-import-node');
|
2019-05-05 18:10:48 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { presets, plugins };
|