Turbopack: add minServerChunkSize and maxMergeServerChunkSize options (#100712)
### What?
Adds two experimental options under `experimental.turbopackChunking`:
- `minServerChunkSize` — the minimum chunk size used by Turbopack's
production chunker for Node.js server-side JavaScript.
- `maxMergeServerChunkSize` — the size above which a Node.js server
chunk is never merged with other chunks.
Both apply only to the Node.js server chunking context (production
builds only). Edge chunking is unchanged and not configurable.
### Why?
`minChunkSize` / `maxMergeChunkSize` only affect client-side chunking.
The Node.js server context used hardcoded thresholds, so there was no
way to tune server chunking (e.g. to trade fewer, larger server chunks
against duplication).
Edge is intentionally left out: Edge functions have a much smaller size
limit, so its existing hardcoded thresholds (min `20000`, no max merge
limit) are kept as-is.
### How?
- The options follow the same path as the existing client thresholds:
config type + zod schema → `TurbopackChunkingConfig` /
`TurbopackChunking` in `next-core` → `Project` →
`ServerChunkingContextOptions`, used by both the regular and the
`_with_client_assets` Node.js variants.
- When unset, the previously hardcoded Node.js values are used (min
`4000`, max merge `100000`), so default output is unchanged.
- Only the ECMAScript chunk type is affected; client chunking, CSS
chunking and the edge chunking context are untouched.
- Docs: new "Server Chunks" section in the `turbopackChunking` reference
(noting that Edge isn't affected), and the client thresholds are now
explicitly described as client-side.
- Tests: the existing `test/production/app-dir/turbopack-chunking` suite
gains Node.js server cases that change each server option in isolation
(relative to a merge-everything baseline) and assert the server chunk
count changes.
### Verification
- `pnpm test-start-turbo
test/production/app-dir/turbopack-chunking/turbopack-chunking.test.ts`
(local native build), plain and with the Cache Components CI env
(`__NEXT_CACHE_COMPONENTS=true
__NEXT_EXPERIMENTAL_CACHED_NAVIGATIONS=true
__NEXT_EXPERIMENTAL_SERVER_COMPONENTS_HMR_CANCELLATION=true`)
- One-off check: an edge build emits exactly the same chunks with the
options unset, set to `0` / `1`, or set to very large values
<!-- NEXT_JS_LLM -->
<!-- fleet 504cbf6c-3b96-4c51-aced-526e81854446 -->
---------
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>