mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1051] [MERGED] fix(routing): discover nested parallel slot sub-routes from layout-only parents #1053
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#1053
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/1051
Author: @NathanDrake2406
Created: 5/4/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @james-elicx
Base:
main← Head:fix/nested-parallel-routes-no-parent-page📝 Commits (6)
9cebf1efix(routing): discover nested parallel slot sub-routes from layout-only parentsd1fc365fix(routing): correct patternsStructurallyEquivalent tree-node comparisonbfaf811fix(routing): scan synthetic routes in structural conflict checkd12aecbtest(routing): cover structural conflict skip for synthetic parallel routesc3a83f9fix(routing): guard discoverSlotSubRoutes to layout-only UI routes70d9a19fix(routing): scan synthetic routes in structural conflict check + regression test📊 Changes
8 files changed (+208 additions, -4 deletions)
View changed files
📝
packages/vinext/src/routing/app-route-graph.ts(+49 -4)📝
tests/app-route-graph.test.ts(+76 -0)📝
tests/app-router.test.ts(+15 -0)➕
tests/fixtures/app-basic/app/parallel-nested/home/@parallelB/default.tsx(+3 -0)➕
tests/fixtures/app-basic/app/parallel-nested/home/@parallelB/nested/page.tsx(+8 -0)➕
tests/fixtures/app-basic/app/parallel-nested/home/layout.tsx(+8 -0)➕
tests/fixtures/app-basic/app/parallel-nested/layout.tsx(+8 -0)📝
tests/routing.test.ts(+41 -0)📄 Description
What this changes
Nested parallel routes now work when the parent segment has a layout but no
page.tsx. Previously,discoverSlotSubRoutesinapp-route-graph.tsskipped any parent route without apagePath, so parallel slot sub-pages like@parallelB/nested/page.tsxunderhome/layout.tsx(with nohome/page.tsx) were never discovered as valid URL routes.This is a high-value App Router parity fix. Next.js explicitly tests this shape in
parallel-routes-and-interception:app/parallel-nested/home/layout.tsxapp/parallel-nested/home/@parallelB/default.tsxapp/parallel-nested/home/@parallelB/nested/page.tsx...creates a valid
/parallel-nested/home/nestedroute even though there is nohome/page.tsx.Approach
The fix makes four targeted changes to
discoverSlotSubRoutes:Remove the hard
pagePathrequirement. Layout-only routes with parallel slots can still own nested slot sub-routes.Compute
parentPageDirfrom the innermost layout whenpagePathis null. This keeps slot ownership checks working correctly for layout-only routes.Relax the
childrenDefault(default.tsx) requirement, but only for layout-only parent routes. When a parent HAS a children page,default.tsxis still required as a fallback for the synthetic sub-route. Layout-only parents do not need this fallback because the children slot was never occupied at the parent level.Add structural-conflict detection before creating synthetic routes. This prevents layout-only root routes from generating synthetic routes that collide with existing page routes differing only by param name (e.g.
/shop/:idvs/shop/:name), whichvalidateRoutePatternsrejects. The slot content for the existing route is handled byfindMirroredSlotPageinstead.Validation
tests/routing.test.ts: "discovers nested parallel slot sub-routes from layout-only parent" (ported from Next.js test suite)tests/app-router.test.ts: "renders nested parallel route from layout-only parent"tests/fixtures/app-basic/app/parallel-nested/matching the Next.js reference fixturetests/routing.test.ts(106 tests)tests/app-route-graph.test.ts(11 tests)tests/app-router.test.ts(301 tests)tests/intercepting-routes-build.test.ts(1 test)Risks / follow-ups
findMirroredSlotPageis unchanged.References
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.