fix(next): register the chunk groups that are chunked (#99749)
### What? Registers chunk groups in the module graph exactly as output code chunks them, in two places: - **Pages layout segments**: `_document` and `_app` are registered as their own `Entry` groups (`layout_chunk_group_entry`), in both the per-page (dev) graph chain and the whole-app `entries()`. `internal_ssr_chunk` chunks them as `ChunkGroup::Entry(vec![layout])` instead of `ChunkGroup::Shared(layout)`. - **turbopack-cli dev**: `create_web_entry_source` registers one `Entry` group per entry, with the same entries `DevHtmlAsset` chunks: the runtime entries followed by the entry for evaluatable modules, or the module alone otherwise. It passes `runtime_entries` without `with_entry(entry)`, because `DevHtmlAsset` appends the entry itself. ### Why? A chunk group is identified by its key, and for an `Entry` group that is its ordered entries. The next PR in the stack looks every chunked group up in `ChunkGroupInfo` by key, so a chunked group the graph didn't register fails. - Pages layouts were declared `Shared(layout)`. The whole-app graph also registers the standalone `/_document` and `/_app` endpoints' `Entry([module])` group for the same module and keeps only one root group per module, so `Shared(layout)` wasn't registered there. - turbopack-cli registered a single `Entry` group with all entries and runtime entries, while `DevHtmlAsset` chunks one group per entry (with the entry appended twice). No output change is intended: the same modules are chunked, but the registered groups now match them. This is PR 3 of an eight-PR stack (on top of #99100, already merged): 1. #98733 — canonical chunk-group identity 2. #99686 — chunk several chunk groups in one `chunk_group` call 3. **This PR** — register the chunk groups that are chunked 4. #98734 — use graph-derived merged groups 5. #99750 — chunking takes a `ChunkGroupKey` 6. #98823 — Pages Router dev client graph chaining 7. #98685 — chunk-group availability bitmaps 8. #99050 — keyed chunk-group index lookups ### Verification - Workspace `cargo clippy --all-targets -D warnings`, `cargo check --workspace --all-targets`, `cargo fmt --check` - Turbopack snapshots: 132 passed, no snapshot changes - `turbo-tasks` + `turbopack-core` + `next-core` unit tests: 362 passed - Turbopack production and dev `404-page-router` (custom `_document` / `_app`): 25/25, 12/12 <!-- 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