fix(rolldown): remove empty common chunks for advanced chunking#9550
Open
aminpaks wants to merge 2 commits into
Open
fix(rolldown): remove empty common chunks for advanced chunking#9550aminpaks wants to merge 2 commits into
aminpaks wants to merge 2 commits into
Conversation
083b89f to
d3b7bd1
Compare
Add graph-level empty common chunk elimination for advanced chunking.\n\n- Remove only non-entry common JS/TS chunks made entirely of metadata-confirmed re-export barrels.\n- Preserve chunks that import CSS so asset/hash ownership stays intact.\n- Retarget importer chunks to any side-effect chunks those barrels forwarded.\n- Treat no-replacement pure barrels as renderless unassigned modules in downstream passes.\n- Document the optimizer boundary.
Add rolldown#6677 regression coverage separately from the implementation.\n\n- Cover empty common chunk removal for side-effect and pure-barrel cases.\n- Keep barrels emitted when they are dynamic import targets.\n- Keep chunks that anchor external imports, CommonJS wrappers, or runtime-helper state.\n- Snapshot output so future guard changes cannot silently delete unsafe chunks.
d3b7bd1 to
3b34d12
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Manual/advanced chunking could leave a barrel module in its own common chunk after its re-export declarations resolved to symbols in other chunks. The chunk rendered as an empty JS file, but entry chunks still imported it.
This adds an empty-common-chunk optimization that removes only graph-proven ESM re-export facades. Before marking the chunk removed, the optimizer retargets importers to any live side-effectful dependencies forwarded through the removed chunk, so load-order side effects are preserved without source-string re-export detection.
Related: #8625 is an earlier attempt at the same #6677 issue. This PR takes a graph-level approach so chunk removal can stay conservative around side effects, dynamic imports, runtime helpers, CJS wrappers, externals, and CSS-owning modules.
Fixes #6677.
Disclosure: AI tools assisted with investigation and implementation. I reviewed, tested, and take responsibility for the submitted changes.