mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #997] [MERGED] refactor(build): move route classification injection behind a typed planner #1010
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#1010
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/997
Author: @NathanDrake2406
Created: 5/1/2026
Status: ✅ Merged
Merged: 5/2/2026
Merged by: @james-elicx
Base:
main← Head:nathan/build-classification-injector📝 Commits (2)
e0645bdrefactor(build): move route classification injection behind a typed planner6eee62erefactor(build): tighten classification stub validation📊 Changes
3 files changed (+377 additions, -108 deletions)
View changed files
➕
packages/vinext/src/build/route-classification-injector.ts(+168 -0)📝
packages/vinext/src/index.ts(+28 -108)➕
tests/route-classification-injector.test.ts(+181 -0)📄 Description
What this changes
Moves build-time route classification injection out of the Vite
generateBundlehook and into a normal typed module. The hook now only adapts final RSC chunks and module info, then applies the patch plan returned byroute-classification-injector.This follows the project principle: codegen should describe the app shape; normal modules should implement behavior. The generated RSC entry still emits stable
__VINEXT_CLASSand__VINEXT_CLASS_REASONSstubs plus per-route call sites. The new module owns drift detection, Layer 2 module-graph classification, Layer 1 priority, debug reason patching, and source-map invalidation.Why
The previous hook mixed Vite shell concerns with classification behavior, so important edge cases were only practical to exercise through plugin integration builds. That made a compatibility-sensitive path harder to reason about and easier to regress when generated source shape, Rolldown output, or classification policy changes.
Relevant Next.js source context:
dynamicandrevalidatesegment configApproach
planRouteClassificationInjection()as the functional core for the final RSC classification patch.index.ts: gather chunks, adapt Rollup/Rolldown module info, apply the returned patch, and clear the consumed manifest.Validation
vp test run tests/route-classification-injector.test.ts tests/route-classification-manifest.test.ts tests/build-time-classification-integration.test.tsvp check packages/vinext/src/build/route-classification-injector.ts packages/vinext/src/index.ts tests/route-classification-injector.test.tsvp run vinext#buildvp run vinext#buildcompleted with the existing package-build unresolved virtual module warnings forvirtual:vinext-rsc-entry,private-next-instrumentation-client, andvirtual:vite-rsc/client-references.Risks / follow-ups
This is intentionally scoped to classification injection. It does not change the generated RSC entry shape, route manifest collection, or runtime probe behavior.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
otherfield #1047