mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #986] [MERGED] refactor(app-router): extract app page dispatch #1001
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#1001
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/986
Author: @NathanDrake2406
Created: 4/30/2026
Status: ✅ Merged
Merged: 5/1/2026
Merged by: @james-elicx
Base:
main← Head:nathan/extract-app-page-dispatch📝 Commits (2)
888ca29refactor(app-router): extract app page dispatch6938714chore: rerun ci📊 Changes
8 files changed (+1264 additions, -3188 deletions)
View changed files
📝
knip.ts(+1 -0)📝
packages/vinext/src/entries/app-rsc-entry.ts(+43 -438)➕
packages/vinext/src/server/app-page-dispatch.ts(+632 -0)📝
packages/vinext/src/server/app-page-request.ts(+5 -5)📝
tests/__snapshots__/entry-templates.test.ts.snap(+252 -2574)➕
tests/app-page-dispatch.test.ts(+278 -0)📝
tests/app-router.test.ts(+39 -171)📝
tests/entry-templates.test.ts(+14 -0)📄 Description
What changed
This extracts App Router page request orchestration out of the generated RSC entry and into
packages/vinext/src/server/app-page-dispatch.ts.The generated entry now describes app shape and request wiring only: matched route, params, component tree builder, boundary render callbacks, middleware context, cache keys, and module loaders. The normal runtime module owns behavior: method policy, force-static/error setup, ISR cache read/regeneration, dynamic params validation, intercepting route responses, page element build error handling, lifecycle render delegation, and special-error fallback routing.
Why
This follows the principle that codegen should describe the app shape while normal modules implement behavior. The prior generated template mixed route-specific imports with a large page dispatch pipeline, which made orchestration harder to type, test, review, and evolve independently from route manifest generation.
Behavior tests
Added
tests/app-page-dispatch.test.tswith response-level behavior coverage for the new dispatch module:dynamicParams = falsereturns 404 for paths outside generated paramsThese tests assert HTTP-visible outcomes: status, headers, and response body. They avoid asserting dispatch call counts or generated implementation details.
Next.js references
Next.js uses a similar separation between generated app-page shape and runtime page rendering modules:
AppPageRouteModuleAppPageRouteModuleis the runtime module boundary for app page renderingAppPageRouteModule.render()delegates torenderToHTMLOrFlightrenderToHTMLOrFlightImplowns the app render orchestrationrenderToHTMLOrFlightexposes the stable runtime entrypointValidation
vp check --fix knip.ts packages/vinext/src/entries/app-rsc-entry.ts packages/vinext/src/server/app-page-dispatch.ts packages/vinext/src/server/app-page-request.ts tests/app-page-dispatch.test.ts tests/app-router.test.ts tests/entry-templates.test.ts tests/__snapshots__/entry-templates.test.ts.snapvp test run tests/app-page-dispatch.test.tsvp test run tests/app-page-dispatch.test.ts tests/entry-templates.test.ts tests/app-router.test.ts tests/app-page-render.test.ts tests/app-page-request.test.ts tests/app-page-cache.test.tsvp run knip --no-progressRisk coverage
Covered the main behavioral risks through dedicated dispatch behavior tests plus the App Router integration suite: dev/prod App Router rendering, RSC/HTML responses, ISR cache reads and writes, route handler separation, middleware header propagation, dynamic params validation, intercepting routes, not-found/forbidden/unauthorized boundaries, and generated-entry delegation assertions.
The generated-code tests intentionally assert only the delegation contract now. Runtime dispatch behavior is covered by
tests/app-page-dispatch.test.ts, existing helper tests, and the App Router integration suite.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.