Skip to content

Commit 51cd3c7

Browse files
authored
Merge pull request webpack#11751 from Knagis/webpack-issue-11743
fix: handle star import name collisions in module concatenation
2 parents b5b423e + 0a8529f commit 51cd3c7

5 files changed

Lines changed: 34 additions & 1 deletion

File tree

lib/optimize/ConcatenatedModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ class ConcatenatedModule extends Module {
999999
const name = reference.identifier.name;
10001000
if (ConcatenationScope.isModuleReference(name)) {
10011001
const match = ConcatenationScope.matchModuleReference(name);
1002-
if (!match || match.ids.length < 1) continue;
1002+
if (!match) continue;
10031003
const binding = getFinalBinding(
10041004
moduleGraph,
10051005
modulesWithInfo[match.index],
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { foo } from "./module";
2+
3+
it("should handle star import with name collision", () => {
4+
expect(foo()).toBe("1 21 2");
5+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as c from "cmodule";
2+
3+
export function foo() {
4+
// variable name matches the imported package name
5+
const cmodule = c([1, 2]);
6+
return cmodule + cmodule;
7+
}

test/cases/optimize/concat-star-import/node_modules/cmodule/index.js

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cases/optimize/concat-star-import/node_modules/cmodule/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)