[PR #965] [MERGED] refactor: extract app prerender endpoints #987

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

📋 Pull Request Information

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

Base: mainHead: nathan/extract-prerender-endpoints


📝 Commits (1)

  • 026ffe9 refactor: extract app prerender endpoints

📊 Changes

5 files changed (+449 additions, -254 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+29 -74)
packages/vinext/src/server/app-prerender-endpoints.ts (+156 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+66 -180)
tests/app-prerender-endpoints.test.ts (+180 -0)
📝 tests/entry-templates.test.ts (+18 -0)

📄 Description

Summary

  • Move App Router internal prerender endpoint behavior out of the generated RSC entry and into server/app-prerender-endpoints.ts.
  • Keep codegen focused on app shape: generateStaticParamsMap and the optional Pages Router SSR route-loader closure are still emitted by the entry.
  • Add direct helper coverage for static params, Pages getStaticPaths, disabled prerender mode, malformed/absent route data, and endpoint errors.
  • Update entry-template assertions/snapshots so /__vinext/prerender/* request handling does not drift back into generated code.

Why

The generated RSC entry had accumulated request parsing, prerender-mode gating, static params dispatch, Pages getStaticPaths dispatch, JSON response shaping, and error handling for /__vinext/prerender/*. That violates the intended boundary: codegen should describe the app shape; normal modules should implement behavior.

This keeps route-specific app data in codegen while moving the runtime behavior into a typed module that can be tested without generating or executing the full entry.

Next.js references

Validation

  • vp test run tests/app-prerender-endpoints.test.ts tests/entry-templates.test.ts tests/prerender.test.ts
  • vp check
  • vp run vinext#build

🔄 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/965 **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/extract-prerender-endpoints` --- ### 📝 Commits (1) - [`026ffe9`](https://github.com/cloudflare/vinext/commit/026ffe9c1c4d3b2ef5c7227e86eb5305a0278118) refactor: extract app prerender endpoints ### 📊 Changes **5 files changed** (+449 additions, -254 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+29 -74) ➕ `packages/vinext/src/server/app-prerender-endpoints.ts` (+156 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+66 -180) ➕ `tests/app-prerender-endpoints.test.ts` (+180 -0) 📝 `tests/entry-templates.test.ts` (+18 -0) </details> ### 📄 Description ## Summary - Move App Router internal prerender endpoint behavior out of the generated RSC entry and into `server/app-prerender-endpoints.ts`. - Keep codegen focused on app shape: `generateStaticParamsMap` and the optional Pages Router SSR route-loader closure are still emitted by the entry. - Add direct helper coverage for static params, Pages `getStaticPaths`, disabled prerender mode, malformed/absent route data, and endpoint errors. - Update entry-template assertions/snapshots so `/__vinext/prerender/*` request handling does not drift back into generated code. ## Why The generated RSC entry had accumulated request parsing, prerender-mode gating, static params dispatch, Pages `getStaticPaths` dispatch, JSON response shaping, and error handling for `/__vinext/prerender/*`. That violates the intended boundary: codegen should describe the app shape; normal modules should implement behavior. This keeps route-specific app data in codegen while moving the runtime behavior into a typed module that can be tested without generating or executing the full entry. ## Next.js references - Next.js records app static path results from build workers as `workerResult.prerenderedRoutes`: [`packages/next/src/build/index.ts#L2384-L2408`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/build/index.ts#L2384-L2408) - Next.js production serving reads static path/fallback data from the prerender manifest: [`packages/next/src/server/base-server.ts#L1949-L1971`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/base-server.ts#L1949-L1971) - Next.js dev serving invokes dynamic static path resolution through the server runtime flow: [`packages/next/src/server/base-server.ts#L2351-L2367`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/server/base-server.ts#L2351-L2367) - Pages Router templates hoist `getStaticPaths` from userland into route modules: [`packages/next/src/build/templates/pages.ts#L17-L23`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/build/templates/pages.ts#L17-L23) - App page runtime consumes build-time fallback route params from prerender metadata: [`packages/next/src/build/templates/app-page.ts#L1108-L1124`](https://github.com/vercel/next.js/blob/e1bb911c14e4ea3c6bb8cc98871ffdee317d513f/packages/next/src/build/templates/app-page.ts#L1108-L1124) ## Validation - `vp test run tests/app-prerender-endpoints.test.ts tests/entry-templates.test.ts tests/prerender.test.ts` - `vp check` - `vp run vinext#build` --- <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:24 +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#987
No description provided.