chore: only apply lazy cjs module transform on cli and core (#10443)

This commit is contained in:
Huáng Jùnliàng 2019-09-27 16:53:27 -04:00 committed by GitHub
parent b459f6a0a4
commit 5f1970433d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,8 +80,7 @@ module.exports = function(api) {
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
// Explicitly use the lazy version of CommonJS modules.
convertESM ? ["@babel/transform-modules-commonjs", { lazy: true }] : null,
convertESM ? "@babel/transform-modules-commonjs" : null,
].filter(Boolean),
overrides: [
{
@ -92,18 +91,17 @@ module.exports = function(api) {
],
},
{
test: "./packages/babel-register",
test: ["./packages/babel-cli", "./packages/babel-core"],
plugins: [
// Override the root options to disable lazy imports for babel-register
// because otherwise the require hook will try to lazy-import things
// leading to dependency cycles.
convertESM ? "@babel/transform-modules-commonjs" : null,
// Explicitly use the lazy version of CommonJS modules.
convertESM
? ["@babel/transform-modules-commonjs", { lazy: true }]
: null,
].filter(Boolean),
},
{
test: "./packages/babel-polyfill",
presets: [["@babel/env", envOptsNoTargets]],
plugins: [["@babel/transform-modules-commonjs", { lazy: false }]],
},
{
// The vast majority of our src files are modules, but we use