Skip to content

Commit

Permalink
fix: handle star import name collisions in module concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
Knagis committed Oct 20, 2020
1 parent b5b423e commit d39747f
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 @@ -1125,7 +1125,7 @@ class ConcatenatedModule extends Module {
info.module.readableIdentifier(requestShortener)
);
allUsedNames.add(externalName);
info.name = externalName;
info.name = externalName + "__WEBPACK_CONCAT_EXTERNAL_";
break;
}
}
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 d39747f

Please sign in to comment.