fix logic
This commit is contained in:
parent
a8fa685cfa
commit
1ed956114f
|
@ -161,7 +161,7 @@ Reflect.defineProperty(Function.prototype, "m", {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let wreqNotInitializedLogged = false;
|
let wreqFallbackApplied = false;
|
||||||
|
|
||||||
function patchFactory(id: PropertyKey, factory: ModuleFactory) {
|
function patchFactory(id: PropertyKey, factory: ModuleFactory) {
|
||||||
const originalFactory = factory;
|
const originalFactory = factory;
|
||||||
|
@ -302,22 +302,25 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) {
|
||||||
let [module, exports, require] = args;
|
let [module, exports, require] = args;
|
||||||
|
|
||||||
if (wreq == null) {
|
if (wreq == null) {
|
||||||
// Make sure the require argument is actually the WebpackRequire function
|
if (!wreqFallbackApplied) {
|
||||||
if (typeof require === "function" && require.m != null) {
|
wreqFallbackApplied = true;
|
||||||
const { stack } = new Error();
|
|
||||||
const webpackInstanceFileName = stack?.match(/\/assets\/(.+?\.js)/)?.[1];
|
// Make sure the require argument is actually the WebpackRequire function
|
||||||
logger.warn(
|
if (typeof require === "function" && require.m != null) {
|
||||||
"WebpackRequire was not initialized, falling back to WebpackRequire passed to the first called patched module factory (" +
|
const { stack } = new Error();
|
||||||
`id: ${String(id)}` + interpolateIfDefined`, WebpackInstance origin: ${webpackInstanceFileName}` +
|
const webpackInstanceFileName = stack?.match(/\/assets\/(.+?\.js)/)?.[1];
|
||||||
")"
|
logger.warn(
|
||||||
);
|
"WebpackRequire was not initialized, falling back to WebpackRequire passed to the first called patched module factory (" +
|
||||||
_initWebpack(require);
|
`id: ${String(id)}` + interpolateIfDefined`, WebpackInstance origin: ${webpackInstanceFileName}` +
|
||||||
} else if (IS_DEV) {
|
")"
|
||||||
if (!wreqNotInitializedLogged) {
|
);
|
||||||
wreqNotInitializedLogged = true;
|
_initWebpack(require);
|
||||||
|
} else if (IS_DEV) {
|
||||||
logger.error("WebpackRequire was not initialized, running modules without patches instead.");
|
logger.error("WebpackRequire was not initialized, running modules without patches instead.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_DEV) {
|
||||||
return originalFactory.apply(this, args);
|
return originalFactory.apply(this, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue