Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back deferred require() calls in core and cli #14028

Merged
merged 1 commit into from Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 17 additions & 14 deletions babel.config.js
Expand Up @@ -73,6 +73,12 @@ module.exports = function (api) {
"eslint/*/test",
];

const lazyRequireSources = [
"./packages/babel-cli",
"./packages/babel-core",
"./packages/babel-preset-env/src/available-plugins.js",
];

switch (env) {
// Configs used during bundling builds.
case "standalone":
Expand Down Expand Up @@ -191,20 +197,6 @@ module.exports = function (api) {
test: ["packages/babel-generator"].map(normalize),
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 && {
test: ["./packages/babel-node/src"].map(normalize),
// Used to conditionally import kexec
Expand All @@ -215,8 +207,19 @@ module.exports = function (api) {
assumptions: sourceAssumptions,
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 && {
test: sources.map(normalize),
exclude: lazyRequireSources.map(normalize),
plugins: [
[
"@babel/transform-modules-commonjs",
Expand Down
@@ -1,5 +1,6 @@
import { parseSync, traverse } from "@babel/core";
import { shouldTransform } from "../lib/util.js";
import babel from "@babel/core";
const { parseSync, traverse } = babel;

function getPath(input, parserOpts = {}) {
let targetPath;
Expand Down
@@ -1,5 +1,6 @@
import { parseSync, traverse } from "@babel/core";
import { shouldTransform } from "../lib/util.js";
import babel from "@babel/core";
const { parseSync, traverse } = babel;

function getPath(input, parserOpts = {}) {
let targetPath;
Expand Down
@@ -1,5 +1,6 @@
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) {
let targetPath;
Expand Down