fix: ensure ordering of assign chunk name#1981
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
| // - entry chunks are always before other chunks | ||
| // - static chunks are always before dynamic chunks | ||
| // - other chunks has stable order at per entry chunk level | ||
| let sorted_chunk_idx_vec = chunks |
There was a problem hiding this comment.
rolldown/crates/rolldown/src/stages/generate_stage/code_splitting.rs
Lines 169 to 216 in cc41c94
chunk is already sorted here. Could we just use chunks.indices().collect<Vec<_>>?
There was a problem hiding this comment.
The share chunks ordering is not stable because we using unstale ordering at https://github.com/rolldown/rolldown/blob/main/crates/rolldown/src/stages/generate_stage/code_splitting.rs#L141
There was a problem hiding this comment.
If we fix it look like it could be get expected stable ordering for assgin name
There was a problem hiding this comment.
The share chunks ordering is not stable because we using unstale ordering at https://github.com/rolldown/rolldown/blob/main/crates/rolldown/src/stages/generate_stage/code_splitting.rs#L141
Shared chunks are sorted by their first module's execution order. It seems stable.
rolldown/crates/rolldown/src/stages/generate_stage/code_splitting.rs
Lines 204 to 209 in cc41c94
rolldown/crates/rolldown/src/stages/generate_stage/code_splitting.rs
Lines 163 to 167 in cc41c94
There was a problem hiding this comment.
rolldown/crates/rolldown/src/stages/generate_stage/code_splitting.rs
Lines 169 to 216 in cc41c94
chunk is already sorted here. Could we just use
chunks.indices().collect<Vec<_>>?
Oh. I missing the your meanings. Here the order is not correct, because the share chunk execute order could be at first. But the entry chunks should be at first for assign name.
There was a problem hiding this comment.
rolldown/crates/rolldown/src/stages/generate_stage/code_splitting.rs
Lines 182 to 191 in cc41c94
Probably should this logic.
There was a problem hiding this comment.
If we fix it look like it could be get expected stable ordering for assgin name
Here I have a try to changed it, but looke like the sorted_modules hasn't dynamic import ids.
Benchmarks Rust |
Description
The esbuild using
Chunk#bitsto sorted chunks, but the order ofChunk#bitsis not stable, egBitSet(0) 00000001_00000000>BitSet(8) 00000000_00000001. It couldn't ensure the order of dynamic chunks and common chunks.Consider the compare
Chunk#exec_ordershould be faster thanChunk#bits, we useChunk#exec_orderto sort chunks.Note Here could be make sure the order of chunks.