fix logic

This commit is contained in:
Nuckyz 2024-05-26 05:46:53 -03:00
parent a8fa685cfa
commit 1ed956114f
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -161,7 +161,7 @@ Reflect.defineProperty(Function.prototype, "m", {
}
});
let wreqNotInitializedLogged = false;
let wreqFallbackApplied = false;
function patchFactory(id: PropertyKey, factory: ModuleFactory) {
const originalFactory = factory;
@ -302,6 +302,9 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) {
let [module, exports, require] = args;
if (wreq == null) {
if (!wreqFallbackApplied) {
wreqFallbackApplied = true;
// Make sure the require argument is actually the WebpackRequire function
if (typeof require === "function" && require.m != null) {
const { stack } = new Error();
@ -313,11 +316,11 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) {
);
_initWebpack(require);
} else if (IS_DEV) {
if (!wreqNotInitializedLogged) {
wreqNotInitializedLogged = true;
logger.error("WebpackRequire was not initialized, running modules without patches instead.");
}
}
if (IS_DEV) {
return originalFactory.apply(this, args);
}
}