refactor: introduce createAppRscHandler#999
Closed
NathanDrake2406 wants to merge 2 commits intocloudflare:mainfrom
Closed
refactor: introduce createAppRscHandler#999NathanDrake2406 wants to merge 2 commits intocloudflare:mainfrom
NathanDrake2406 wants to merge 2 commits intocloudflare:mainfrom
Conversation
d164d37 to
db09233
Compare
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is stacked on #986
This introduces
createAppRscHandler()and moves the top-level App Router RSC request lifecycle out of the generated entry and into a normal typed runtime module.The generated entry now stays focused on app shape:
The runtime helper now owns request behavior:
next.config.jsheader applicationI also trimmed dead surface from the new seam by removing top-level handler options that were not actually consumed there (
allowedOrigins,maxActionBodySize). Those remain owned by the action helpers, which is a better fit for the “codegen describes shape, normal modules implement behavior” split.Why
app-rsc-entry.tshad accumulated too much request orchestration. That made the generated output harder to reason about, harder to test directly, and too easy to grow in the wrong direction.This refactor keeps codegen responsible for describing the app-specific graph while moving stable behavior into importable runtime code with focused tests.
That layering is closer to how Next.js is structured:
Tests
vp check packages/vinext/src/entries/app-rsc-entry.ts packages/vinext/src/server/app-rsc-handler.ts tests/app-rsc-handler.test.ts tests/app-router.test.ts tests/entry-templates.test.tsvp test run tests/entry-templates.test.ts -uvp test run tests/app-rsc-handler.test.ts 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.ts