Unverified Commit 05e6b825 authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

[ppr] Data route fixes (#66109)

Ensures that app routes (like the `favicon.ico` added in the test case
in this PR which is represented as an app route) do not have a prefetch
RSC also attached.
parent 39ccec89
......@@ -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}`
)
......@@ -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}`
)
......@@ -2894,7 +2895,7 @@ export default async function build(
fallback: appDynamicParamPaths.has(originalAppPath)
? null
: false,
dataRouteRegex: isRouteHandler
dataRouteRegex: !dataRoute
? null
: normalizeRouteRegex(
getNamedRouteRegex(
......@@ -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$'
)
),
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment