@@ -2860,15 +2860,19 @@ export default async function build(
28602860
28612861 if ( ! hasDynamicData && isDynamicRoute ( originalAppPath ) ) {
28622862 const normalizedRoute = normalizePagePath ( page )
2863- const dataRoute = path . posix . join (
2864- `${ normalizedRoute } ${ RSC_SUFFIX } `
2865- )
28662863
2867- let prefetchDataRoute : string | null | undefined
2864+ let dataRoute : string | null = null
2865+ if ( ! isRouteHandler ) {
2866+ dataRoute = path . posix . join ( `${ normalizedRoute } ${ RSC_SUFFIX } ` )
2867+ }
28682868
2869+ let prefetchDataRoute : string | null | undefined
2870+ if ( isRouteHandler ) {
2871+ prefetchDataRoute = null
2872+ }
28692873 // We write the `.prefetch.rsc` when the app has PPR enabled, so
28702874 // always add the prefetch data route to the manifest.
2871- if ( isAppPPREnabled ) {
2875+ else if ( isAppPPREnabled ) {
28722876 prefetchDataRoute = path . posix . join (
28732877 `${ normalizedRoute } ${ RSC_PREFETCH_SUFFIX } `
28742878 )
@@ -2896,7 +2900,7 @@ export default async function build(
28962900 fallback : appDynamicParamPaths . has ( originalAppPath )
28972901 ? null
28982902 : false ,
2899- dataRouteRegex : isRouteHandler
2903+ dataRouteRegex : ! dataRoute
29002904 ? null
29012905 : normalizeRouteRegex (
29022906 getNamedRouteRegex (
@@ -2905,18 +2909,17 @@ export default async function build(
29052909 ) . re . source . replace ( / \( \? : \\ \/ \) \? \$ $ / , '\\.rsc$' )
29062910 ) ,
29072911 prefetchDataRoute,
2908- prefetchDataRouteRegex :
2909- isRouteHandler || ! prefetchDataRoute
2910- ? undefined
2911- : normalizeRouteRegex (
2912- getNamedRouteRegex (
2913- prefetchDataRoute . replace ( / \. p r e f e t c h \. r s c $ / , '' ) ,
2914- false
2915- ) . re . source . replace (
2916- / \( \? : \\ \/ \) \? \$ $ / ,
2917- '\\.prefetch\\.rsc$'
2918- )
2919- ) ,
2912+ prefetchDataRouteRegex : ! prefetchDataRoute
2913+ ? undefined
2914+ : normalizeRouteRegex (
2915+ getNamedRouteRegex (
2916+ prefetchDataRoute . replace ( / \. p r e f e t c h \. r s c $ / , '' ) ,
2917+ false
2918+ ) . re . source . replace (
2919+ / \( \? : \\ \/ \) \? \$ $ / ,
2920+ '\\.prefetch\\.rsc$'
2921+ )
2922+ ) ,
29202923 }
29212924 }
29222925 }
0 commit comments