Skip to content

Commit

Permalink
fix: ensure prefetch data routes are always added when app has ppr en…
Browse files Browse the repository at this point in the history
…abled (#66102)

When PPR is enabled, we should always write the prefetch RSC routes to
ensure that the builder and FS cache can use it.
  • Loading branch information
wyattjoh committed May 23, 2024
1 parent 74be1f6 commit 6c1c004
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,8 @@ export default async function build(
? await readManifest<AppBuildManifest>(appBuildManifestPath)
: undefined

const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)

const appPathRoutes: Record<string, string> = {}

if (appDir) {
Expand Down Expand Up @@ -1814,7 +1816,7 @@ export default async function build(
minimalMode: ciEnvironment.hasNextSupport,
allowedRevalidateHeaderKeys:
config.experimental.allowedRevalidateHeaderKeys,
isAppPPREnabled: checkIsAppPPREnabled(config.experimental.ppr),
isAppPPREnabled,
})

incrementalCacheIpcPort = cacheInitialization.ipcPort
Expand Down Expand Up @@ -2789,7 +2791,10 @@ export default async function build(
}

let prefetchDataRoute: string | null | undefined
if (experimentalPPR) {

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

let prefetchDataRoute: string | null | undefined
if (experimentalPPR) {

// We write the `.prefetch.rsc` when the app has PPR enabled, so
// always add the prefetch data route to the manifest.
if (isAppPPREnabled) {
prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
)
Expand Down

0 comments on commit 6c1c004

Please sign in to comment.