mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #842] [MERGED] feat(build): wire build-time layout classification into RSC entry #893
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#893
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/842
Author: @NathanDrake2406
Created: 4/14/2026
Status: ✅ Merged
Merged: 4/20/2026
Merged by: @james-elicx
Base:
main← Head:feat/pr-768-5-build-classification-wire📝 Commits (10+)
ac081b1feat(build): wire build-time layout classification into the generated RSC entry70e7a03refactor(build): address Copilot review comments on PR 84283f4ddfrefactor: address review comments on build classification PRe91408dtest: update entry-templates snapshots for module-load comment4707e2crefactor: address second round of review comments7ef82d0refactor: address third round of review comments28b317frefactor: address subagent review findings6827a50refactor: hoist build-time classification helpers and rename layer1 bindingc03ed6bPreserve module-graph reasons in classification manifest22a1731Share module-graph static reason type📊 Changes
12 files changed (+1427 additions, -70 deletions)
View changed files
➕
packages/vinext/src/build/layout-classification-types.ts(+56 -0)📝
packages/vinext/src/build/layout-classification.ts(+69 -10)📝
packages/vinext/src/build/report.ts(+31 -15)➕
packages/vinext/src/build/route-classification-manifest.ts(+237 -0)📝
packages/vinext/src/entries/app-rsc-entry.ts(+12 -1)📝
packages/vinext/src/index.ts(+180 -0)📝
tests/__snapshots__/entry-templates.test.ts.snap(+84 -0)📝
tests/app-router.test.ts(+21 -0)📝
tests/build-report.test.ts(+31 -14)➕
tests/build-time-classification-integration.test.ts(+249 -0)📝
tests/layout-classification.test.ts(+62 -30)➕
tests/route-classification-manifest.test.ts(+395 -0)📄 Description
Summary
Adds a build-time layout classification pipeline. A Rollup
generateBundlehook patches the__VINEXT_CLASSstub in the generated RSC entry with a real dispatch table, built from segment-config (Layer 1) and module-graph (Layer 2) analysis. The runtime probe loop inapp-page-execution.tsconsults this table and skips the Layer 3 dynamic-isolation probe for layouts already proved static or dynamic at build time.This lands as standalone reusable infrastructure. Build-time classification is the precondition for any future layout-skip optimization, independent of how the skip mechanism is implemented at runtime.
What changes
build/route-classification-manifest.tsbridges the classifier with the entry template codegen.build/layout-classification-types.tscarries the taggedLayoutBuildClassificationandClassificationReasontypes.ClassificationReasonis consumed by the debug sidecar follow-up; including it here keeps the codegen machinery self-contained.classifyLayoutSegmentConfiginbuild/report.tsnow returnsLayoutBuildClassificationinstead of"static" | "dynamic" | null.classificationblock in the generated RSC entry threadsbuildTimeClassificationsthrough.generateBundlehook fails loudly if it sees__VINEXT_CLASSreferenced without the recognized stub body, so the codegen template and the plugin cannot silently drift.Context
This was originally PR 5 of a 6-PR stack (#838, #839, #840, #841, this PR, #843). #838 and #839 landed. #840 and #841 are closed: their server-side skip mechanism relied on rewriting the React Flight wire-format payload on egress, which proved too coupled to React-internal tag conventions for a framework that does not vendor React. The skip-mechanism design is being reworked separately around render-time omission rather than byte-level filtering.
This PR is unaffected by that decision. The classifier is needed for any approach. The runtime probe loop already short-circuits on its output, so this PR is useful even before the new skip mechanism lands.
#843 still depends on this PR for the
ClassificationReasonmachinery.Test plan
tests/route-classification-manifest.test.ts(44 tests)tests/build-time-classification-integration.test.ts(5 tests)tests/build-report.test.tstests/layout-classification.test.tstests/app-router.test.ts(build-time classification dispatch stub cases)tests/entry-templates.test.ts(snapshot regenerated)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.