diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index df6ef897d..c675c4125 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -377,8 +377,8 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) { // There are (at the time of writing) 11 modules exporting the window // Make these non enumerable to improve webpack search performance - if (require.c && (exports === window || exports?.default === window)) { - Object.defineProperty(require.c, id, { + if ((exports === window || exports?.default === window) && typeof require === "function" && require.c != null) { + define(require.c, id, { value: require.c[id], enumerable: false });