-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
update topLevelDeclarations for ConcatenatedModule #15315
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
Conversation
For maintainers only:
|
df032ad
to
f0de515
Compare
update top level declarations for ConcatenatedModule in code generation step
f0de515
to
fee6837
Compare
- add topLevelDeclarations to code generation results - set topLevelDeclarations=undefined if any child topLevelDeclarations=undefined
- add topLevelDeclarations to code generation results - set topLevelDeclarations=undefined if any child topLevelDeclarations=undefined
lib/library/AssignLibraryPlugin.js
Outdated
{ chunk, codeGenerationResults }, | ||
{ options, compilation } | ||
) { | ||
let topLevelDeclarations = | ||
module.buildInfo && module.buildInfo.topLevelDeclarations; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using both topLevelDeclarations maybe it's better to use
const topLevelDeclarations =
(data && data.get("topLevelDeclarations")) ||
(module.buildInfo && module.buildInfo.topLevelDeclarations);
So the topLevelDeclarations from code generations overrides the original topLevelDeclarations, since it's basically a better version of it. It includes renames, which means some original topLevelDeclarations might be no longer in the code generation topLevelDeclarations, e. g. all reserved names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming it should also be possible that buildInfo.topLevelDeclarations
is not set but data.topLevelDeclarations
is, we also need to improve that piece of code:
webpack/lib/javascript/JavascriptModulesPlugin.js
Lines 1107 to 1108 in 13a3bc1
(!entryModule.buildInfo || | |
!entryModule.buildInfo.topLevelDeclarations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the topLevelDeclarations from code generations overrides the original topLevelDeclarations, since it's basically a better version of it. It includes renames, which means some original topLevelDeclarations might be no longer in the code generation topLevelDeclarations, e. g. all reserved names.
yeah, reserved names (globals) is a case.
Assuming it should also be possible that buildInfo.topLevelDeclarations is not set but data.topLevelDeclarations
not sure that this wont be a breaking change.. I have change hooks api ( added codeGenerationResults
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw case
{
entry: {
index: path.resolve(__dirname, "./index.js")
},
output: {
library: "setTimeout",
libraryExport: "default"
},
optimization: {
concatenateModules: true
}
}
will not work.. since "global" setTimeout
points to variable
Thanks |
update top level declarations for ConcatenatedModule in code generation step
What kind of change does this PR introduce?
fixes #13022
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
nothing