-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module concatenation produces invalid output due to name collision #11743
Comments
// EXTERNAL MODULE: leads to the assumption that you are using classnames as external module? is this correct? |
im still not sure if this is a bug or the type of classnames npm module type is not valid thus it becomes type external webpack/lib/optimize/ConcatenatedModule.js Line 832 in 9342540
you could try to use webpack externals configuration to rename the module.
which will lead to the following output
|
I think it is bug |
i created a branch with actual working example suggested usage from the npm author
|
@code1x1 do you suggest that I go and list every single dependency that I might have as external in webpack config?
Also how is switching from |
It's external to the concatenated module. No necessary external to the whole bundle. Anyway that's a bug. |
just an example that it is not limited to
|
should work 🙂 but your right the import should be prefixed. |
Here is what i know so far:
because this if statement is executed
which results in this if statement being executed
after that the
im still not sure how to fix the problem without breaking a lot of other cases.. |
This is probably not a very good hack but still - perhaps until a more proper solution is found, the workaround could be to add suffix for every external in concatenated modules? webpack/lib/optimize/ConcatenatedModule.js Line 1128 in b5b423e
case "external": {
const externalName = this.findNewName(
"",
allUsedNames,
namespaceObjectUsedNames,
info.module.readableIdentifier(requestShortener)
);
allUsedNames.add(externalName);
- info.name = externalName;
+ info.name = externalName + "__WEBPACK_CONCAT_EXTERNAL_";
break;
} |
type external probably has to stay that name because external could also reference an external library which this maybe required to reference it. |
Created a PR with the change mentioned above. The issue reproduced nicely in the tests, which is nice :) |
Bug report
What is the current behavior?
with module concatenation this is compiled as
This reproduces in development mode, with
concatenateModules: true
and in full production mode. The code listed above has to be in a imported file, not directly in the entry.If the current behavior is a bug, please provide the steps to reproduce.
yarn
yarn webpack
What is the expected behavior?
imported variable to have some sort of prefix/suffix to avoid name collisions or it preserves the original name as specified in the source
Other relevant information:
webpack version: 5.1.3
Node.js version: 12.13.1
Operating System: Win10
Additional tools:
The text was updated successfully, but these errors were encountered: