refactor(turbopack): chunk chunk groups by key (#99750)
### What?
Chunking APIs take chunk group keys instead of chunk groups:
- `ChunkingContext::chunk_group` takes `chunk_groups:
SmallVec<[ChunkGroupKey; 1]>`.
- `evaluated_chunk_group`, `entry_chunk_group` and all
`ChunkingContextExt` helpers take `chunk_group: ChunkGroupKey`.
- The browser and Node.js chunking contexts resolve each key with the
new `ChunkGroupInfo::get_chunk_group(key)` and chunk the registered
group, using its entries for evaluation and bootstrapping.
- Callers pass keys: `ChunkGroupKey::{Entry, Async, Isolated, Shared}`,
or the `.key()` of a graph-derived merged group.
### Why?
Chunking already resolved every group by key and failed if the group
wasn't registered, so the entries a caller passed in were redundant at
best and inconsistent with the graph at worst. With key-only APIs,
`ChunkGroupInfo` is the single source of a group's contents, and callers
can no longer construct a group that disagrees with the module graph.
This is PR 4 of a six-PR stack, based on `canary` (#98733, #99686 and
#99749 are already merged):
1. #98823 — Pages Router dev client graph chaining
2. #99910 — regression test for Pages Router `_app` availability
(#99789)
3. #98734 — use graph-derived merged groups
4. **This PR** — chunking takes a `ChunkGroupKey`
5. #98685 — chunk-group availability bitmaps
6. #99050 — keyed chunk-group index lookups
### Verification
- The tree of this PR is identical to the previous #98734 head, which
passed:
- Workspace `cargo clippy --all-targets -D warnings`, per-layer `cargo
fmt` and workspace check
- Turbopack snapshots: 132 passed, no snapshot changes
- Turbopack production and dev `404-page-router`,
`app-dir/actions/app-action` and `app-dir/initial-css-order`; production
`edge-pages-support`, `app-dir/css-order` and
`layout-segment-chunk-sharing`
<!-- NEXT_JS_LLM -->
<!-- fleet 4f67c6f7-bbe2-454b-9a17-822a60ef8f7e -->
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