[PR #953] [MERGED] refactor(app-router): delegate RSC route matching #980

Closed
opened 2026-05-06 13:11:22 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/953
Author: @NathanDrake2406
Created: 4/29/2026
Status: Merged
Merged: 4/29/2026
Merged by: @james-elicx

Base: mainHead: nathan/rsc-route-codegen


📝 Commits (1)

  • 2026394 refactor(app-router): delegate RSC route matching

📊 Changes

5 files changed (+336 additions, -613 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+17 -91)
packages/vinext/src/server/app-rsc-route-matching.ts (+139 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+60 -522)
tests/app-rsc-route-matching.test.ts (+106 -0)
📝 tests/entry-templates.test.ts (+14 -0)

📄 Description

What this changes

Moves App Router RSC route matching, intercept lookup construction, intercept param merging, and dynamic metadata route pattern matching out of the generated RSC entry and into server/app-rsc-route-matching.ts.

This PR is independent of #952 and is based on main. It may conflict lightly with other app-rsc-entry.ts refactors if they merge first, but it does not require the stream-hints PR to land.

Why

app-rsc-entry.ts still owned request-path matching behavior inside generated source strings. That made the behavior hard to unit test directly and kept real runtime logic in the codegen layer.

Approach

  • Add a typed runtime helper for RSC route matching and intercept matching.
  • Keep unavoidable route import and manifest emission in the generator, since route modules need generated import bindings.
  • Delegate generated matchRoute, findIntercept, and dynamic metadata route pattern matching to the helper.
  • Replace the earlier string-emitter extraction with focused helper tests and entry-template delegation assertions.

Validation

  • vp test run tests/app-rsc-route-matching.test.ts tests/entry-templates.test.ts
  • vp check packages/vinext/src/server/app-rsc-route-matching.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-rsc-route-matching.test.ts tests/entry-templates.test.ts tests/__snapshots__/entry-templates.test.ts.snap
  • vp run vinext#build

Build completed with the existing unresolved virtual import warnings for vinext virtual modules.

Risks / follow-ups

This keeps route manifest import emission in app-rsc-entry.ts because those generated imports still need lexical module bindings. A later slice can target another runtime subsystem, but this PR avoids metadata emission, ISR, middleware, actions, and boundary behavior.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/953 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 4/29/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `nathan/rsc-route-codegen` --- ### 📝 Commits (1) - [`2026394`](https://github.com/cloudflare/vinext/commit/202639495f2bc0010d7a0cb8f604d50a044da2df) refactor(app-router): delegate RSC route matching ### 📊 Changes **5 files changed** (+336 additions, -613 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+17 -91) ➕ `packages/vinext/src/server/app-rsc-route-matching.ts` (+139 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+60 -522) ➕ `tests/app-rsc-route-matching.test.ts` (+106 -0) 📝 `tests/entry-templates.test.ts` (+14 -0) </details> ### 📄 Description ## What this changes Moves App Router RSC route matching, intercept lookup construction, intercept param merging, and dynamic metadata route pattern matching out of the generated RSC entry and into `server/app-rsc-route-matching.ts`. This PR is independent of #952 and is based on `main`. It may conflict lightly with other `app-rsc-entry.ts` refactors if they merge first, but it does not require the stream-hints PR to land. ## Why `app-rsc-entry.ts` still owned request-path matching behavior inside generated source strings. That made the behavior hard to unit test directly and kept real runtime logic in the codegen layer. ## Approach - Add a typed runtime helper for RSC route matching and intercept matching. - Keep unavoidable route import and manifest emission in the generator, since route modules need generated import bindings. - Delegate generated `matchRoute`, `findIntercept`, and dynamic metadata route pattern matching to the helper. - Replace the earlier string-emitter extraction with focused helper tests and entry-template delegation assertions. ## Validation - `vp test run tests/app-rsc-route-matching.test.ts tests/entry-templates.test.ts` - `vp check packages/vinext/src/server/app-rsc-route-matching.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-rsc-route-matching.test.ts tests/entry-templates.test.ts tests/__snapshots__/entry-templates.test.ts.snap` - `vp run vinext#build` Build completed with the existing unresolved virtual import warnings for vinext virtual modules. ## Risks / follow-ups This keeps route manifest import emission in `app-rsc-entry.ts` because those generated imports still need lexical module bindings. A later slice can target another runtime subsystem, but this PR avoids metadata emission, ISR, middleware, actions, and boundary behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:22 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#980
No description provided.