gitlab-org--gitlab-foss/babel.config.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-02-20 15:27:23 -05:00
/* eslint-disable import/no-commonjs, filenames/match-regex */
2018-10-02 17:11:53 -04:00
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',
2019-01-09 01:20:56 -05:00
'@babel/plugin-proposal-private-methods',
'@babel/plugin-proposal-optional-chaining',
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'],
},
]);
}
// add rewire support when running tests
if (BABEL_ENV === 'karma' || BABEL_ENV === 'coverage') {
plugins.push('babel-plugin-rewire');
}
2019-04-25 09:38:15 -04:00
// Jest is running in node environment, so we need additional plugins
const isJest = Boolean(process.env.JEST_WORKER_ID);
2019-04-25 09:38:15 -04:00
if (isJest) {
plugins.push('@babel/plugin-transform-modules-commonjs');
/*
without the following, babel-plugin-istanbul throws an error:
https://gitlab.com/gitlab-org/gitlab-foss/issues/58390
*/
plugins.push('babel-plugin-dynamic-import-node');
2018-08-29 16:45:53 -04:00
}
2018-10-02 17:11:53 -04:00
module.exports = { presets, plugins };