Skip to content

Commit 6390240

Browse files
committed
rewrite module reference correctly after replacing ConcatenatedModule
fixes webpack#7443
1 parent 4f4a2ba commit 6390240

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/optimize/ModuleConcatenationPlugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,13 @@ class ModuleConcatenationPlugin {
286286
}
287287
compilation.modules.push(newModule);
288288
for (const reason of newModule.reasons) {
289-
reason.dependency.module = newModule;
289+
if (reason.dependency.module === concatConfiguration.rootModule)
290+
reason.dependency.module = newModule;
291+
if (
292+
reason.dependency.redirectedModule ===
293+
concatConfiguration.rootModule
294+
)
295+
reason.dependency.redirectedModule = newModule;
290296
}
291297
// TODO: remove when LTS node version contains fixed v8 version
292298
// @see https://github.com/webpack/webpack/pull/6613
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { a } from "pmodule";
2+
3+
it("should not crash with null id", function() {
4+
expect(a).toBe("a");
5+
});
6+
7+
if(Math === undefined)
8+
console.log(module); // prevent scope hoisting of this module

0 commit comments

Comments
 (0)