2022-06-08 08:08:46 -04:00
|
|
|
const coreJSVersion = require('./node_modules/core-js/package.json').version;
|
|
|
|
|
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',
|
2022-06-08 08:08:46 -04:00
|
|
|
corejs: { version: coreJSVersion, proposals: true },
|
2018-10-02 17:11:53 -04:00
|
|
|
modules: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// include stage 3 proposals
|
|
|
|
const plugins = [
|
|
|
|
'@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',
|
2021-07-15 11:09:41 -04:00
|
|
|
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/336216
|
|
|
|
'@babel/plugin-proposal-optional-chaining',
|
|
|
|
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/336216
|
|
|
|
'@babel/plugin-proposal-nullish-coalescing-operator',
|
2020-01-21 19:08:47 -05:00
|
|
|
'lodash',
|
2018-10-02 17:11:53 -04:00
|
|
|
];
|
|
|
|
|
2022-06-15 08:09:10 -04:00
|
|
|
// Jest is running in node environment
|
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) {
|
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' };
|