@@ -24,7 +24,6 @@ import {
2424 PROXY_FILENAME ,
2525 PAGES_DIR_ALIAS ,
2626 INSTRUMENTATION_HOOK_FILENAME ,
27- RSC_PREFETCH_SUFFIX ,
2827 RSC_SUFFIX ,
2928 PRERENDER_REVALIDATE_HEADER ,
3029 PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER ,
@@ -200,11 +199,6 @@ import { RenderingMode } from './rendering-mode'
200199import { InvariantError } from '../shared/lib/invariant-error'
201200import { HTML_LIMITED_BOT_UA_RE_STRING } from '../shared/lib/router/utils/is-bot'
202201import type { UseCacheTrackerKey } from './webpack/plugins/telemetry-plugin/use-cache-tracker-utils'
203- import {
204- buildInversePrefetchSegmentDataRoute ,
205- buildPrefetchSegmentDataRoute ,
206- type PrefetchSegmentDataRoute ,
207- } from '../server/lib/router-utils/build-prefetch-segment-data-route'
208202
209203import { turbopackBuild } from './turbopack-build'
210204import { isFileSystemCacheEnabledForBuild } from '../shared/lib/turbopack/utils'
@@ -228,8 +222,12 @@ import {
228222 writeValidatorFile ,
229223} from '../server/lib/router-utils/route-types-utils'
230224import { Lockfile } from './lockfile'
231- import { validateAppPaths } from './validate-app-paths'
225+ import {
226+ buildPrefetchSegmentDataRoute ,
227+ type PrefetchSegmentDataRoute ,
228+ } from '../server/lib/router-utils/build-prefetch-segment-data-route'
232229import { generateRoutesManifest } from './generate-routes-manifest'
230+ import { validateAppPaths } from './validate-app-paths'
233231
234232type Fallback = null | boolean | string
235233
@@ -456,7 +454,6 @@ export type RoutesManifest = {
456454 varyHeader : string
457455 prefetchHeader : typeof NEXT_ROUTER_PREFETCH_HEADER
458456 suffix : typeof RSC_SUFFIX
459- prefetchSuffix : typeof RSC_PREFETCH_SUFFIX
460457 prefetchSegmentHeader : typeof NEXT_ROUTER_SEGMENT_PREFETCH_HEADER
461458 prefetchSegmentDirSuffix : typeof RSC_SEGMENTS_DIR_SUFFIX
462459 prefetchSegmentSuffix : typeof RSC_SEGMENT_SUFFIX
@@ -3212,26 +3209,6 @@ export default async function build(
32123209 dataRoute = path . posix . join ( `${ normalizedRoute } ${ RSC_SUFFIX } ` )
32133210 }
32143211
3215- let prefetchDataRoute : string | null = null
3216- // While we may only write the `.rsc` when the route does not
3217- // have PPR enabled, we still want to generate the route when
3218- // deployed so it doesn't 404. If the app has PPR enabled, we
3219- // should add this key.
3220- if (
3221- ! isAppRouteHandler &&
3222- isAppPPREnabled &&
3223- // Don't add a prefetch data route if we have
3224- // cacheComponents enabled. This is
3225- // because we don't actually use the prefetch data route in
3226- // this case. This only applies if we have PPR enabled for
3227- // this route.
3228- ! ( config . cacheComponents && isRoutePPREnabled )
3229- ) {
3230- prefetchDataRoute = path . posix . join (
3231- `${ normalizedRoute } ${ RSC_PREFETCH_SUFFIX } `
3232- )
3233- }
3234-
32353212 const meta = collectMeta ( metadata )
32363213 const status =
32373214 route . pathname === UNDERSCORE_NOT_FOUND_ROUTE
@@ -3252,7 +3229,7 @@ export default async function build(
32523229 initialExpireSeconds : cacheControl . expire ,
32533230 srcRoute : page ,
32543231 dataRoute,
3255- prefetchDataRoute,
3232+ prefetchDataRoute : undefined ,
32563233 allowHeader : ALLOWED_HEADERS ,
32573234 }
32583235 } else {
@@ -3326,20 +3303,6 @@ export default async function build(
33263303 ( r ) => r . page === route . pathname
33273304 )
33283305 if ( ! isAppRouteHandler && isAppPPREnabled ) {
3329- if (
3330- // Don't add a prefetch data route if we have
3331- // cacheComponents enabled. This is
3332- // because we don't actually use the prefetch data route in
3333- // this case. This only applies if we have PPR enabled for
3334- // this route.
3335- ! config . cacheComponents ||
3336- ! isRoutePPREnabled
3337- ) {
3338- prefetchDataRoute = path . posix . join (
3339- `${ normalizedRoute } ${ RSC_PREFETCH_SUFFIX } `
3340- )
3341- }
3342-
33433306 // If the dynamic route wasn't found, then we need to create
33443307 // it. This ensures that for each fallback shell there's an
33453308 // entry in the app routes manifest which enables routing for
@@ -3407,27 +3370,6 @@ export default async function build(
34073370 builtSegmentDataRoute
34083371 )
34093372 }
3410- // If the route has fallback root params, and we don't have
3411- // any segment paths, we need to write the inverse prefetch
3412- // segment data route so that it can first rewrite the /_tree
3413- // request to the prefetch RSC route. We also need to set the
3414- // `hasFallbackRootParams` flag so that we can simplify the
3415- // route regex for matching.
3416- else if (
3417- route . fallbackRootParams &&
3418- route . fallbackRootParams . length > 0
3419- ) {
3420- dynamicRoute . hasFallbackRootParams = true
3421- dynamicRoute . prefetchSegmentDataRoutes = [
3422- buildInversePrefetchSegmentDataRoute (
3423- dynamicRoute . page ,
3424- // We use the special segment path of `/_tree` because it's
3425- // the first one sent by the client router so it's the only
3426- // one we need to rewrite to the regular prefetch RSC route.
3427- '/_tree'
3428- ) ,
3429- ]
3430- }
34313373 }
34323374
34333375 pageInfos . set ( route . pathname , {
0 commit comments