next.js
6c3295f9 - [Segment Bundling] [Scaffolding] Track which segments can be omitted from prefetch (#91438)

Commit
41 days ago
[Segment Bundling] [Scaffolding] Track which segments can be omitted from prefetch (#91438) Some segments in a route don't benefit from static prefetching. A segment with runtime prefetching enabled will be fetched and computed at runtime instead, and a segment with `instant = false` is not prefetchable at all. There's no reason to pay the prefetch cost for these segments — neither the server (measuring sizes, generating responses) nor the client (fetching, caching) gains anything from including them. ### Pass-through segments This commit teaches the hint computation pass to identify these segments and mark them accordingly. During the size measurement traversal, disabled segments are skipped (zero size contribution) and act as transparent pass-throughs: parent data flows through them to the nearest static descendant rather than being blocked. This means a small static layout can still be bundled into a grandchild's response even when the intermediate segment is dynamic. ### No behavioral changes yet The actual server output and client fetching behavior don't change yet — disabled segments still produce standalone responses for now. A follow-up commit will use these hints to actually omit the segments from the output and teach the client to handle the gaps. ### Head (metadata) inlining The head (metadata/viewport) inlining logic is also updated: the head is only inlined into page segments (not layouts, since pages may access additional params like `searchParams`), and routes with runtime prefetch skip static head inlining entirely since the runtime response already includes the head.
Author
Parents
Loading