Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ppr] Data route fixes #66109

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2791,10 +2791,9 @@ export default async function build(
}

let prefetchDataRoute: string | null | undefined

// We write the `.prefetch.rsc` when the app has PPR enabled, so
// always add the prefetch data route to the manifest.
if (isAppPPREnabled) {
if (!isRouteHandler && experimentalPPR) {
prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
)
Expand Down Expand Up @@ -2858,15 +2857,17 @@ export default async function build(

if (!hasDynamicData && isDynamicRoute(originalAppPath)) {
const normalizedRoute = normalizePagePath(page)
const dataRoute = path.posix.join(
`${normalizedRoute}${RSC_SUFFIX}`
)

let prefetchDataRoute: string | null | undefined
let dataRoute: string | null = null
if (!isRouteHandler) {
dataRoute = path.posix.join(`${normalizedRoute}${RSC_SUFFIX}`)
}

let prefetchDataRoute: string | undefined

// We write the `.prefetch.rsc` when the app has PPR enabled, so
// always add the prefetch data route to the manifest.
if (isAppPPREnabled) {
if (!isRouteHandler && isAppPPREnabled) {
prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
)
Expand Down Expand Up @@ -2894,7 +2895,7 @@ export default async function build(
fallback: appDynamicParamPaths.has(originalAppPath)
? null
: false,
dataRouteRegex: isRouteHandler
dataRouteRegex: !dataRoute
? null
: normalizeRouteRegex(
getNamedRouteRegex(
Expand All @@ -2903,18 +2904,17 @@ export default async function build(
).re.source.replace(/\(\?:\\\/\)\?\$$/, '\\.rsc$')
),
prefetchDataRoute,
prefetchDataRouteRegex:
isRouteHandler || !prefetchDataRoute
? undefined
: normalizeRouteRegex(
getNamedRouteRegex(
prefetchDataRoute.replace(/\.prefetch\.rsc$/, ''),
false
).re.source.replace(
/\(\?:\\\/\)\?\$$/,
'\\.prefetch\\.rsc$'
)
),
prefetchDataRouteRegex: !prefetchDataRoute
? undefined
: normalizeRouteRegex(
getNamedRouteRegex(
prefetchDataRoute.replace(/\.prefetch\.rsc$/, ''),
false
).re.source.replace(
/\(\?:\\\/\)\?\$$/,
'\\.prefetch\\.rsc$'
)
),
}
}
}
Expand Down
Binary file added test/e2e/app-dir/ppr-incremental/app/favicon.ico
Binary file not shown.
Loading