-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport: fix prerender issue with intercepting routes + generateStat…
…icParams (#75170) Backports the testcase added in #75167 in [9bf61bc](9bf61bc). Confirmed failure via [this run](https://github.com/vercel/next.js/actions/runs/12898849331/job/35966678688?pr=75170) Adds the fix in [0ab1e32](0ab1e32). This change is identical to the code used in canary, which was added as part of the `rootParams` feature via #73816 ([ref](https://github.com/vercel/next.js/blob/d12e2e82b778eef8393f47944a258a55c6c508fe/packages/next/src/build/static-paths/app.ts#L316-L317)) This regression was caused by `segments` containing all possible segments (including parallel routes), not just the page segment. As a result, `paramKeys` was incorrectly being calculated. We don't need to traverse the segments to determine the param keys: we have the route regex & matcher, it's more reliable to extract it from that.
- Loading branch information
Showing
5 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/interception-dynamic-segment/app/@modal/[...catchAll]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function CatchAll() { | ||
return null | ||
} |
3 changes: 3 additions & 0 deletions
3
...app-dir/interception-dynamic-segment/app/@modal/generate-static-params/(.)[slug]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return 'intercepted' | ||
} |
19 changes: 19 additions & 0 deletions
19
test/e2e/app-dir/interception-dynamic-segment/app/generate-static-params/[slug]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
type Props = { | ||
params: Promise<{ slug: string }> | ||
} | ||
|
||
export default async function Page({ params }: Props) { | ||
const { slug } = await params | ||
return <div>Hello {slug}</div> | ||
} | ||
|
||
export function generateStaticParams() { | ||
return [ | ||
{ slug: 'a' }, | ||
{ slug: 'b' }, | ||
{ slug: 'c' }, | ||
{ slug: 'd' }, | ||
{ slug: 'e' }, | ||
{ slug: 'f' }, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters