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( ...@@ -2791,10 +2791,9 @@ export default async function build(
} }
let prefetchDataRoute: string | null | undefined let prefetchDataRoute: string | null | undefined
// We write the `.prefetch.rsc` when the app has PPR enabled, so // We write the `.prefetch.rsc` when the app has PPR enabled, so
// always add the prefetch data route to the manifest. // always add the prefetch data route to the manifest.
if (isAppPPREnabled) { if (!isRouteHandler && experimentalPPR) {
prefetchDataRoute = path.posix.join( prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}` `${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
) )
...@@ -2858,15 +2857,17 @@ export default async function build( ...@@ -2858,15 +2857,17 @@ export default async function build(
if (!hasDynamicData && isDynamicRoute(originalAppPath)) { if (!hasDynamicData && isDynamicRoute(originalAppPath)) {
const normalizedRoute = normalizePagePath(page) 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 // We write the `.prefetch.rsc` when the app has PPR enabled, so
// always add the prefetch data route to the manifest. // always add the prefetch data route to the manifest.
if (isAppPPREnabled) { if (!isRouteHandler && isAppPPREnabled) {
prefetchDataRoute = path.posix.join( prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}` `${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
) )
...@@ -2894,7 +2895,7 @@ export default async function build( ...@@ -2894,7 +2895,7 @@ export default async function build(
fallback: appDynamicParamPaths.has(originalAppPath) fallback: appDynamicParamPaths.has(originalAppPath)
? null ? null
: false, : false,
dataRouteRegex: isRouteHandler dataRouteRegex: !dataRoute
? null ? null
: normalizeRouteRegex( : normalizeRouteRegex(
getNamedRouteRegex( getNamedRouteRegex(
...@@ -2903,8 +2904,7 @@ export default async function build( ...@@ -2903,8 +2904,7 @@ export default async function build(
).re.source.replace(/\(\?:\\\/\)\?\$$/, '\\.rsc$') ).re.source.replace(/\(\?:\\\/\)\?\$$/, '\\.rsc$')
), ),
prefetchDataRoute, prefetchDataRoute,
prefetchDataRouteRegex: prefetchDataRouteRegex: !prefetchDataRoute
isRouteHandler || !prefetchDataRoute
? undefined ? undefined
: normalizeRouteRegex( : normalizeRouteRegex(
getNamedRouteRegex( getNamedRouteRegex(
......
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