mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #968] [MERGED] refactor: Extract app route handler dispatch #989
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#989
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/968
Author: @NathanDrake2406
Created: 4/29/2026
Status: ✅ Merged
Merged: 4/29/2026
Merged by: @james-elicx
Base:
main← Head:nathan/extract-route-handler-dispatch📝 Commits (1)
ecd7f7arefactor: extract app route handler dispatch📊 Changes
5 files changed (+672 additions, -1103 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+27 -171)➕
packages/vinext/src/server/app-route-handler-dispatch.ts(+264 -0)📝
tests/__snapshots__/entry-templates.test.ts.snap(+150 -918)➕
tests/app-route-handler-dispatch.test.ts(+218 -0)📝
tests/app-router.test.ts(+13 -14)📄 Description
What changed
This extracts App Router
route.tsdispatch out of the generated RSC entry and into a normal typed runtime module:server/app-route-handler-dispatch.ts.The generated entry now describes only the app shape and request seams for a matched route handler:
The new dispatcher owns the behavior previously embedded in codegen:
HEAD, auto-OPTIONS, and 405 responsesWhy
Generated entries should describe the application shape. Normal modules should implement behavior. The old
route.tsbranch inentries/app-rsc-entry.tswas still making runtime decisions even though the lower-level policy/cache/execution helpers already existed.This mirrors the shape of Next.js more closely: the build template creates a route module, and the route module owns request handling behavior.
Relevant Next.js references:
app-routebuild template createsAppRouteRouteModuleAppRouteRouteModuleinitializes userland methods and route configAppRouteRouteModule.handle()owns request dispatch and response validationautoImplementMethods()owns auto-HEAD, auto-OPTIONS, and 405 defaultsTests
vp check packages/vinext/src/server/app-route-handler-dispatch.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-route-handler-dispatch.test.ts tests/app-router.test.ts tests/__snapshots__/entry-templates.test.ts.snapvp test run tests/app-route-handler-dispatch.test.ts tests/app-route-handler-execution.test.ts tests/app-route-handler-cache.test.ts tests/app-route-handler-policy.test.ts tests/app-route-handler-response.test.ts tests/app-router.test.ts tests/nextjs-compat/app-routes.test.ts tests/entry-templates.test.ts -t "app route handler dispatch|app route handler|APP_ROUTE ISR|route handler|Route Handlers|Basic HTTP methods|HEAD|OPTIONS|unimplemented method|route handler ISR|catch-all route handler|dev mode|App Router RSC entry template"vp test run tests/entry-templates.test.tsvp run vinext#build🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.