fix(dev): prune dynamic import entry points when their imports are removed#10117
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label graphite: merge-when-ready to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
0928e71 to
d7c462d
Compare
507523a to
9633216
Compare
d7c462d to
818e66b
Compare
9633216 to
11d0c68
Compare
818e66b to
b4374de
Compare
11d0c68 to
3f003ea
Compare
b4374de to
b7d9a8e
Compare
3f003ea to
f8475df
Compare
b7d9a8e to
aabb746
Compare
f8475df to
4338591
Compare
4338591 to
e5138d0
Compare
✅ Deploy Preview for rolldown-rs canceled.
|

Description
Part of #7416. Stacked on #10115. This makes
ScanStageCache::mergeclean up dynamic import entry points when the dynamic imports behind them go away. Until now the entry list only ever grew.Problem
Two related gaps in the entry point handling of
merge:related_stmt_infosrows. The old code removed a re-scanned importer's rows only when the scan output contained a matching entry point, keyed by the incoming rows. When a re-scanned module removed its dynamic import entirely, the scan output had no entry for the target at all, so the importer's old rows stayed behind and kept pointing at statement and node ids of a module version that no longer exists.DynamicImportentry point stayed in the cache forever. Every incremental rebuild kept emitting a chunk for a module nothing imports dynamically anymore, which a fresh full build of the same files would not produce.Fix
extract_if, which is removed.DynamicImportentry whose module no longer has any dynamic edge in theimportersedge list. The edge list is reliable at merge time since fix(dev): update importer relationships of cached modules in incremental build #10107 and fix(dev): revert cache mutations when a partial scan fails #10110. Other entry kinds are untouched.ScanStageCache::create_outputcompensates by filteringDynamicImportentries against module reachability (compute_live_modules, a BFS from the non dynamic entries), so only entries a live module dynamically imports produce chunks, matching a fresh build. This covers the transitive case:mainimportshub,hubdynamically importslazy, and dropping thehubimport frommainmust also stop emitting thelazychunk even thoughhubis never re-scanned.DynamicImportentry for a module that is a configured user entry. The scan localuser_defined_entry_idsset is empty in partial mode, so the existing full scan filter never matched there, and a dynamic import of the entry module produced a second entry row (and a second chunk) for it.Tests
hmr/remove_transitive_dynamic_import_entry:mainstatically importshub,hubdynamically importslazy. Dropping thehubimport frommainremoves thelazychunk from the build output without re-scanninghub; re-adding it revives the chunk.hmr/remove_dynamic_import_entry: two modules dynamically importlazy.jsand drop it one by one. After the first drop the entry survives through the remaining importer. After the second drop thelazy.jschunk disappears from the build output. Re-adding the import brings the entry and the chunk back.DynamicImportentries now must match a fresh full build exactly while a live module imports them; an entry kept in the cache only by orphans' dynamic import records is tolerated, sincecreate_outputfilters it from the output and it exists precisely to make revival cheap (other kinds still allow extras on the incremental side until orphan cleanup lands). Reintroducing the bug locally makes the parity check fail on the new fixture with "dynamic import entry only exists in the incremental state", so the whole HMR suite now guards this behavior.Docs
The entry point step of the
mergealgorithm ininternal-docs/cache/implementation.mdis updated.