Repository navigation
Description
Inside of Rolldown, there're multiple passes touch chunks. Like removing unnecessary ones or do some optimizations. They're all built on top of a bare raw Chunk struct.
Bad: Every pass tries to define its own lanague to do similar stuffs.
Owners:
- feature
avoidRedundantChunkLoadspredicted_static_import_targetstries to predict something
- feature
mergeCommonChunkswould_create_circular_dependencycan_merge_without_changing_entry_signaturetry to predict something
- feature
onDemandWrappingpredicted_static_import_edgestries to predict somethinglowered_static_import_edgesalters the chunk graph
At least 3 passes transform/modify the chunk graph, using their own language.
Bad: Every pass interacts with business logic directly rather than abstracts it into domain properties
The point is separating a feature's business logic from the nature it represents.
preserveEntrySignatures: 'strict' means the entry should keep its export signature. Its nature for chunk optimization is a domain property: this chunk's export surface is frozen, no pass may add exports to it.
Marking the feature on the chunk is not enough. We already do that (chunk.preserve_entry_signature), and the pass is still messy: it still has to know what each feature implies.
!chunk.is_async_entry()
&& !matches!(chunk.preserve_entry_signature, Some(PreserveEntrySignatures::Strict))These two checks are the same domain property spelled as two feature checks: "this chunk's export surface is frozen". A third feature that also freezes the export surface would add a third &&.
Chunks should carry a domain property like export_surface: Frozen | Extendable. Lowering translates every feature onto that one property — preserveEntrySignatures, async entry, whatever comes next.
The optimizer reads the property and never knows the feature exists. The test of a good domain property: multiple features converge onto one.
The worst case today is is_strict_execution_order_enabled(), which forks a whole pass into two graphs inline.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
hyfdev commentedon Aug 17, 2026
Another example is about the side effect nature of modules. There're various concepts to distinguish:
Modules don't have side effects has similar nature to wrapped modules. They both could be moved around during optimization without worrying about execution order effect. Things like these ideally should be unified into one "representation" so the optimizer doesn't need to care about domain fact either "if the module has side effects" or "if the module is wrapped", instead we just say "the module is free to moved around"