mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #998] [MERGED] refactor(routing): extract App Router route graph builder #1011
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#1011
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/998
Author: @NathanDrake2406
Created: 5/1/2026
Status: ✅ Merged
Merged: 5/2/2026
Merged by: @james-elicx
Base:
main← Head:nathan/app-route-graph-builder📝 Commits (1)
3f2072brefactor(routing): extract App Router route graph builder📊 Changes
3 files changed (+1369 additions, -1204 deletions)
View changed files
➕
packages/vinext/src/routing/app-route-graph.ts(+1207 -0)📝
packages/vinext/src/routing/app-router.ts(+8 -1204)➕
tests/app-route-graph.test.ts(+154 -0)📄 Description
What this changes
Extracts App Router route graph construction into
packages/vinext/src/routing/app-route-graph.ts.app-router.tsnow stays focused on the publicappRouter()cache wrapper and request-time trie matching, while the new graph builder owns filesystem scanning, route metadata materialization, validation, synthetic parallel slot routes, and exported route shape types.Why
Will make https://github.com/cloudflare/vinext/issues/726 easier
The App Router routing module had grown into a mixed-purpose file that combined discovery, graph materialization, cache ownership, and request matching. That made route graph changes noisy to review and more likely to collide with App Router runtime entry work.
This keeps the graph-building pressure isolated inside routing code and avoids touching generated entry templates such as
entries/app-rsc-entry.ts.Approach
routing/app-route-graph.ts.buildAppRouteGraph(appDir, matcher)as the direct construction boundary.appRouter()behavior-compatible by delegating to the builder, then caching the returned routes as before.matchAppRoute()and trie caching inapp-router.ts, since those are request-time matching concerns rather than graph construction concerns.Validation
vp test run tests/app-route-graph.test.ts tests/routing.test.ts tests/route-sorting.test.ts tests/page-extensions-routing.test.tsvp run vinext#builddist/routing/app-route-graph.jsvp checkNote: the first
vp checkrun happened before the package build had generated workspace package output and failed onbenchmarks/vinext/vite.config.tsresolvingvinext. Aftervp run vinext#build, rerunningvp checkpassed.Risks / follow-ups
The main risk is accidental drift in synthetic parallel slot route materialization. I covered that with the new graph-builder test plus the existing routing and route sorting suites that exercise slot inheritance, conflict errors, intercepting routes, catch-all validation, and route ordering.
No generated App Router entry files are touched in this PR.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.