Disable "Reentrant plugin detected" error in async mode (#14153)
This commit is contained in:
parent
ab2c578f98
commit
8035ad90f9
@ -6,6 +6,7 @@ import buildDebug from "debug";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import type { Handler } from "gensync";
|
import type { Handler } from "gensync";
|
||||||
import loadCjsOrMjsDefault from "./module-types";
|
import loadCjsOrMjsDefault from "./module-types";
|
||||||
|
import { isAsync } from "../../gensync-utils/async";
|
||||||
|
|
||||||
import { createRequire } from "module";
|
import { createRequire } from "module";
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
@ -149,18 +150,25 @@ function resolveStandardizedName(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOADING_MODULES = new Set();
|
if (!process.env.BABEL_8_BREAKING) {
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var LOADING_MODULES = new Set();
|
||||||
|
}
|
||||||
function* requireModule(type: string, name: string): Handler<unknown> {
|
function* requireModule(type: string, name: string): Handler<unknown> {
|
||||||
if (LOADING_MODULES.has(name)) {
|
if (!process.env.BABEL_8_BREAKING) {
|
||||||
throw new Error(
|
if (!(yield* isAsync()) && LOADING_MODULES.has(name)) {
|
||||||
`Reentrant ${type} detected trying to load "${name}". This module is not ignored ` +
|
throw new Error(
|
||||||
"and is trying to load itself while compiling itself, leading to a dependency cycle. " +
|
`Reentrant ${type} detected trying to load "${name}". This module is not ignored ` +
|
||||||
'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.',
|
"and is trying to load itself while compiling itself, leading to a dependency cycle. " +
|
||||||
);
|
'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOADING_MODULES.add(name);
|
if (!process.env.BABEL_8_BREAKING) {
|
||||||
|
LOADING_MODULES.add(name);
|
||||||
|
}
|
||||||
return yield* loadCjsOrMjsDefault(
|
return yield* loadCjsOrMjsDefault(
|
||||||
name,
|
name,
|
||||||
`You appear to be using a native ECMAScript module ${type}, ` +
|
`You appear to be using a native ECMAScript module ${type}, ` +
|
||||||
@ -175,6 +183,8 @@ function* requireModule(type: string, name: string): Handler<unknown> {
|
|||||||
err.message = `[BABEL]: ${err.message} (While processing: ${name})`;
|
err.message = `[BABEL]: ${err.message} (While processing: ${name})`;
|
||||||
throw err;
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
LOADING_MODULES.delete(name);
|
if (!process.env.BABEL_8_BREAKING) {
|
||||||
|
LOADING_MODULES.delete(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user