Skip to content

Commit

Permalink
Merge pull request #11751 from Knagis/webpack-issue-11743
Browse files Browse the repository at this point in the history
fix: handle star import name collisions in module concatenation
  • Loading branch information
sokra committed Oct 20, 2020
2 parents b5b423e + 0a8529f commit 51cd3c7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/optimize/ConcatenatedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ class ConcatenatedModule extends Module {
const name = reference.identifier.name;
if (ConcatenationScope.isModuleReference(name)) {
const match = ConcatenationScope.matchModuleReference(name);
if (!match || match.ids.length < 1) continue;
if (!match) continue;
const binding = getFinalBinding(
moduleGraph,
modulesWithInfo[match.index],
Expand Down
5 changes: 5 additions & 0 deletions test/cases/optimize/concat-star-import/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { foo } from "./module";

it("should handle star import with name collision", () => {
expect(foo()).toBe("1 21 2");
});
7 changes: 7 additions & 0 deletions test/cases/optimize/concat-star-import/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as c from "cmodule";

export function foo() {
// variable name matches the imported package name
const cmodule = c([1, 2]);
return cmodule + cmodule;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51cd3c7

Please sign in to comment.