mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #780] [MERGED] fix: interleave templates with layouts at each segment level #840
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#840
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/780
Author: @NathanDrake2406
Created: 4/4/2026
Status: ✅ Merged
Merged: 4/5/2026
Merged by: @james-elicx
Base:
main← Head:fix/template-layout-interleaving📝 Commits (2)
8a17341fix: interleave templates with layouts at each segment level78c338cfix: align templates array with layouts to prevent index mismatch📊 Changes
4 files changed (+108 additions, -33 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+9 -4)📝
packages/vinext/src/routing/app-router.ts(+25 -15)📝
packages/vinext/src/server/app-page-route-wiring.tsx(+8 -12)📝
tests/app-page-route-wiring.test.ts(+66 -2)📄 Description
Summary
Before (wrong):
After (matches Next.js):
Next.js nests per segment as:
Layout > Template > ErrorBoundary > Loading > NotFound > children. The separate template batch loop inbuildAppPageRouteElementviolated this by applying all templates after all layouts were already wrapped.The fix removes the separate template loop and integrates template wrapping into the layout loop at each index, between the error boundary and the not-found boundary — matching Next.js's
layout-router.tsxnesting order.Changed files
packages/vinext/src/server/app-page-route-wiring.tsx— moved template wrapping into the layout looptests/app-page-route-wiring.test.ts— added multi-level template interleaving test that verifiesLayout[0] > Template[0] > Layout[1] > Template[1] > PageorderingTest plan
pnpm test tests/app-page-route-wiring.test.ts— 9/9 passpnpm test tests/app-router.test.ts— 285/285 passpnpm test tests/features.test.ts— 264/264 pass🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.