[PR #735] feat(prerender): support layout-level generateStaticParams #806

Open
opened 2026-05-06 13:10:12 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/735
Author: @raed04
Created: 4/1/2026
Status: 🔄 Open

Base: mainHead: feat/layout-generate-static-params-567


📝 Commits (1)

  • a4e39da feat(prerender): support layout-level generateStaticParams (#567)

📊 Changes

4 files changed (+221 additions, -100 deletions)

View changed files

📝 packages/vinext/src/build/prerender.ts (+13 -17)
📝 packages/vinext/src/entries/app-rsc-entry.ts (+65 -12)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+0 -30)
📝 tests/prerender.test.ts (+143 -41)

📄 Description

Summary

Closes #567

Layout files at dynamic segments (e.g. app/[category]/layout.tsx) can export generateStaticParams to provide parent params for nested child routes. Previously only page-level exports were scanned, silently skipping layout-only dynamic segments.

  • Extend generateStaticParamsMap code-gen to emit layout-level entries by walking each route's layouts[] and layoutTreePositions[], with deduplication and page-entry priority
  • Remove routeIndex guard in resolveParentParams — check staticParamsMap directly so layout-only prefixes are resolved
  • Handle null results as pass-through (CF Workers Proxy compatibility) instead of collapsing the param accumulator to []
  • Use decodeRouteSegment for static segments to match convertSegmentsToRouteParts behavior
  • Remove dead routeIndex parameter and Map construction from prerenderApp
  • Update entry-templates snapshots (removed stale TODO comments from 6 snapshots)
  • Add 10 new resolveParentParams tests covering layout-only parents, mixed page/layout, null pass-through, catch-all parents, error propagation, and three-level nesting

Changed files

File What changed
packages/vinext/src/entries/app-rsc-entry.ts Two-pass IIFE for generateStaticParamsMap: page entries then layout entries
packages/vinext/src/build/prerender.ts resolveParentParams simplified signature, null pass-through fix
tests/__snapshots__/entry-templates.test.ts.snap Removed stale TODO comment from 6 snapshots
tests/prerender.test.ts 19 total tests (was 9), removed unused routeIndexFrom helper

Test plan

  • All 19 resolveParentParams unit tests pass
  • All 20 entry-templates snapshot tests pass
  • vp check passes on all changed files (lint + types + format)
  • No test regressions vs base branch (same pre-existing failures)
  • Verify with a real fixture that has layout-level generateStaticParams

🔄 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/735 **Author:** [@raed04](https://github.com/raed04) **Created:** 4/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/layout-generate-static-params-567` --- ### 📝 Commits (1) - [`a4e39da`](https://github.com/cloudflare/vinext/commit/a4e39da53e6b1c2a5e15214f49f3488efb856d96) feat(prerender): support layout-level generateStaticParams (#567) ### 📊 Changes **4 files changed** (+221 additions, -100 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/build/prerender.ts` (+13 -17) 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+65 -12) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+0 -30) 📝 `tests/prerender.test.ts` (+143 -41) </details> ### 📄 Description ## Summary Closes #567 Layout files at dynamic segments (e.g. `app/[category]/layout.tsx`) can export `generateStaticParams` to provide parent params for nested child routes. Previously only page-level exports were scanned, silently skipping layout-only dynamic segments. - **Extend `generateStaticParamsMap` code-gen** to emit layout-level entries by walking each route's `layouts[]` and `layoutTreePositions[]`, with deduplication and page-entry priority - **Remove `routeIndex` guard in `resolveParentParams`** — check `staticParamsMap` directly so layout-only prefixes are resolved - **Handle null results as pass-through** (CF Workers Proxy compatibility) instead of collapsing the param accumulator to `[]` - **Use `decodeRouteSegment`** for static segments to match `convertSegmentsToRouteParts` behavior - **Remove dead `routeIndex` parameter** and Map construction from `prerenderApp` - **Update entry-templates snapshots** (removed stale TODO comments from 6 snapshots) - **Add 10 new `resolveParentParams` tests** covering layout-only parents, mixed page/layout, null pass-through, catch-all parents, error propagation, and three-level nesting ## Changed files | File | What changed | |------|-------------| | `packages/vinext/src/entries/app-rsc-entry.ts` | Two-pass IIFE for `generateStaticParamsMap`: page entries then layout entries | | `packages/vinext/src/build/prerender.ts` | `resolveParentParams` simplified signature, null pass-through fix | | `tests/__snapshots__/entry-templates.test.ts.snap` | Removed stale TODO comment from 6 snapshots | | `tests/prerender.test.ts` | 19 total tests (was 9), removed unused `routeIndexFrom` helper | ## Test plan - [x] All 19 `resolveParentParams` unit tests pass - [x] All 20 `entry-templates` snapshot tests pass - [x] `vp check` passes on all changed files (lint + types + format) - [x] No test regressions vs base branch (same pre-existing failures) - [ ] Verify with a real fixture that has layout-level `generateStaticParams` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#806
No description provided.