-
由 Lukas Eipert 创作于
Once a TC39 proposal becomes part of the ECMAScript spec, babel deprecates the corresponding `@babel/plugin-proposal-*` in favour of a `@babel/plugin-transform-*`. We have been enabling a hardcoded list of plugins. Some for compatibility with webpack@4, some for unknown reasons. We should double check whether we need them, but that should be done in a separate MR. That being said, all plugins we use made it to the ECMAScript standard and we can happily use them as transform plugins.
由 Lukas Eipert 创作于Once a TC39 proposal becomes part of the ECMAScript spec, babel deprecates the corresponding `@babel/plugin-proposal-*` in favour of a `@babel/plugin-transform-*`. We have been enabling a hardcoded list of plugins. Some for compatibility with webpack@4, some for unknown reasons. We should double check whether we need them, but that should be done in a separate MR. That being said, all plugins we use made it to the ECMAScript standard and we can happily use them as transform plugins.
代码所有者
将用户和群组指定为特定文件更改的核准人。 了解更多。
babel.config.js 1.09 KiB
const coreJSVersion = require('./node_modules/core-js/package.json').version;
let presets = [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
bugfixes: true,
corejs: { version: coreJSVersion, proposals: true },
modules: false,
},
],
];
// include stage 3 proposals
const plugins = [
'@babel/plugin-transform-class-properties',
'@babel/plugin-transform-json-strings',
'@babel/plugin-transform-private-methods',
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/229146
'@babel/plugin-transform-arrow-functions',
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/336216
'@babel/plugin-transform-optional-chaining',
// See: https://gitlab.com/gitlab-org/gitlab/-/issues/336216
'@babel/plugin-transform-nullish-coalescing-operator',
'lodash',
];
// Jest is running in node environment
const isJest = Boolean(process.env.JEST_WORKER_ID);
if (isJest) {
presets = [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
];
}
module.exports = { presets, plugins, sourceType: 'unambiguous' };