Sort batched chunk items globally by path (#98433)
### What? Globally order all emitted Turbopack ECMAScript chunk items by module path, including items nested inside batches. Browser and Node.js chunk emitters now consume the same flattened, ordered result. ### Why? The previous ordering compared only the first module in each item or batch group. Remaining modules in a batch stayed together even when their paths belonged elsewhere in the global order, reducing locality between similar modules and slightly worsening gzip compression. For `bench/basic-app`, production JavaScript chunk gzip sizes changed as follows while raw bytes and chunk counts stayed unchanged: | Output | Before | After | Change | |---|---:|---:|---:| | Browser chunks | 1,619,643 B | 1,619,314 B | -329 B (-0.020%) | | Server chunks | 792,379 B | 792,186 B | -193 B (-0.024%) | | Combined | 2,412,022 B | 2,411,500 B | -522 B (-0.022%) | ### How? The shared ECMAScript chunk-content accessor now flattens resolved item and batch groups and sorts every module by `(path, module id)`. Keeping this ordering in the shared layer gives browser and Node.js output identical deterministic behavior and removes duplicated emitter-side sorting. ### Verification - `cargo fmt --all -- --check` - `cargo check -p turbopack-browser -p turbopack-nodejs` - `cargo test -p turbopack-browser -p turbopack-nodejs` - `pnpm build-all` - Clean baseline and candidate production builds of `bench/basic-app` <!-- NEXT_JS_LLM --> <!-- fleet d30d9e3f-6885-4665-ae08-b37fa6151b95 --> --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment