Skip to content

Commit

Permalink
rewrite module reference correctly after replacing ConcatenatedModule
Browse files Browse the repository at this point in the history
fixes #7443
  • Loading branch information
sokra committed May 30, 2018
1 parent 4f4a2ba commit 6390240
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/optimize/ModuleConcatenationPlugin.js
Expand Up @@ -286,7 +286,13 @@ class ModuleConcatenationPlugin {
}
compilation.modules.push(newModule);
for (const reason of newModule.reasons) {
reason.dependency.module = newModule;
if (reason.dependency.module === concatConfiguration.rootModule)
reason.dependency.module = newModule;
if (
reason.dependency.redirectedModule ===
concatConfiguration.rootModule
)
reason.dependency.redirectedModule = newModule;
}
// TODO: remove when LTS node version contains fixed v8 version
// @see https://github.com/webpack/webpack/pull/6613
Expand Down
8 changes: 8 additions & 0 deletions test/cases/optimize/side-effects-scope-hoisting/index.js
@@ -0,0 +1,8 @@
import { a } from "pmodule";

it("should not crash with null id", function() {
expect(a).toBe("a");
});

if(Math === undefined)
console.log(module); // prevent scope hoisting of this module

0 comments on commit 6390240

Please sign in to comment.