Bring back deferred require() calls in core and cli (#14028)
This commit is contained in:
parent
2a3b0b9601
commit
3a85ddfb1b
@ -73,6 +73,12 @@ module.exports = function (api) {
|
|||||||
"eslint/*/test",
|
"eslint/*/test",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const lazyRequireSources = [
|
||||||
|
"./packages/babel-cli",
|
||||||
|
"./packages/babel-core",
|
||||||
|
"./packages/babel-preset-env/src/available-plugins.js",
|
||||||
|
];
|
||||||
|
|
||||||
switch (env) {
|
switch (env) {
|
||||||
// Configs used during bundling builds.
|
// Configs used during bundling builds.
|
||||||
case "standalone":
|
case "standalone":
|
||||||
@ -191,20 +197,6 @@ module.exports = function (api) {
|
|||||||
test: ["packages/babel-generator"].map(normalize),
|
test: ["packages/babel-generator"].map(normalize),
|
||||||
plugins: ["babel-plugin-transform-charcodes"],
|
plugins: ["babel-plugin-transform-charcodes"],
|
||||||
},
|
},
|
||||||
convertESM && {
|
|
||||||
test: [
|
|
||||||
"./packages/babel-cli",
|
|
||||||
"./packages/babel-core",
|
|
||||||
"./packages/babel-preset-env/src/available-plugins.js",
|
|
||||||
].map(normalize),
|
|
||||||
plugins: [
|
|
||||||
// Explicitly use the lazy version of CommonJS modules.
|
|
||||||
[
|
|
||||||
"@babel/transform-modules-commonjs",
|
|
||||||
{ importInterop: importInteropSrc, lazy: true },
|
|
||||||
],
|
|
||||||
],
|
|
||||||
},
|
|
||||||
convertESM && {
|
convertESM && {
|
||||||
test: ["./packages/babel-node/src"].map(normalize),
|
test: ["./packages/babel-node/src"].map(normalize),
|
||||||
// Used to conditionally import kexec
|
// Used to conditionally import kexec
|
||||||
@ -215,8 +207,19 @@ module.exports = function (api) {
|
|||||||
assumptions: sourceAssumptions,
|
assumptions: sourceAssumptions,
|
||||||
plugins: [transformNamedBabelTypesImportToDestructuring],
|
plugins: [transformNamedBabelTypesImportToDestructuring],
|
||||||
},
|
},
|
||||||
|
convertESM && {
|
||||||
|
test: lazyRequireSources.map(normalize),
|
||||||
|
plugins: [
|
||||||
|
// Explicitly use the lazy version of CommonJS modules.
|
||||||
|
[
|
||||||
|
"@babel/transform-modules-commonjs",
|
||||||
|
{ importInterop: importInteropSrc, lazy: true },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
convertESM && {
|
convertESM && {
|
||||||
test: sources.map(normalize),
|
test: sources.map(normalize),
|
||||||
|
exclude: lazyRequireSources.map(normalize),
|
||||||
plugins: [
|
plugins: [
|
||||||
[
|
[
|
||||||
"@babel/transform-modules-commonjs",
|
"@babel/transform-modules-commonjs",
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { parseSync, traverse } from "@babel/core";
|
|
||||||
import { shouldTransform } from "../lib/util.js";
|
import { shouldTransform } from "../lib/util.js";
|
||||||
|
import babel from "@babel/core";
|
||||||
|
const { parseSync, traverse } = babel;
|
||||||
|
|
||||||
function getPath(input, parserOpts = {}) {
|
function getPath(input, parserOpts = {}) {
|
||||||
let targetPath;
|
let targetPath;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { parseSync, traverse } from "@babel/core";
|
|
||||||
import { shouldTransform } from "../lib/util.js";
|
import { shouldTransform } from "../lib/util.js";
|
||||||
|
import babel from "@babel/core";
|
||||||
|
const { parseSync, traverse } = babel;
|
||||||
|
|
||||||
function getPath(input, parserOpts = {}) {
|
function getPath(input, parserOpts = {}) {
|
||||||
let targetPath;
|
let targetPath;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { willPathCastToBoolean } from "../lib/util.js";
|
import { willPathCastToBoolean } from "../lib/util.js";
|
||||||
import { parseSync, traverse } from "@babel/core";
|
import babel from "@babel/core";
|
||||||
|
const { parseSync, traverse } = babel;
|
||||||
|
|
||||||
function getPath(input, parserOpts) {
|
function getPath(input, parserOpts) {
|
||||||
let targetPath;
|
let targetPath;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user