-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
feat: enable tree-shaking for ESM external modules with named imports #19641
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
base: main
Are you sure you want to change the base?
Conversation
…ernal-module-render
Verify that the implementation generates named imports for better tree-shaking
CodSpeed Performance ReportMerging #19641 will degrade performances by 94.11%Comparing Summary
Benchmarks breakdown
|
c6e4dd3
to
7a37133
Compare
5514a63
to
39ee0a6
Compare
@alexander-akait I tried a few different yarn fix commands but couldn't get the lint CI to pass. Could you help fix this? (Might need to update snapshots too, maybe?) |
@3ru You can run |
eeebd81
to
39ee0a6
Compare
This PR completes the implementation started in #19416, resolving the InitFragment handling issue that was blocking the original work. The main problem was that external modules were not generating proper named imports when using module concatenation, instead falling back to namespace imports.
What kind of change does this PR introduce?
Feature completion - This change enable tree-shaking optimization for external ESM modules in the
ModuleConcatenationPlugin
by:1. InitFragment Collection in ModuleConcatenationPlugin
InitFragments
from external modules during code generationchunkInitFragments
for correct import statement generation2. External Module Analysis in
_analyseModule
exportMap
andrawExportMap
based ongetUsedExports()
resultsexternalType === "module"
and outputting ES modules3. ConcatenationScope Integration
Did you add tests for your changes?
Yes, added the
modern-module-tree-shaking-simple
test case that:Does this PR introduce a breaking change?
No
What needs to be documented once your changes are merged?