Unverified Commit 70a2e8d9 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Replace PPR config helpers with cacheComponents checks (#90704)

This PR replaces the legacy PPR configs in the codebase with the
`cacheComponents` config.

Confirmed deployment test passes
https://github.com/vercel/next.js/actions/runs/22533307017

---------
Co-authored-by: 's avatarHendrik Liebau <mail@hendrik-liebau.de>
parent 5719439f
...@@ -2104,7 +2104,7 @@ export async function handleBuildComplete({ ...@@ -2104,7 +2104,7 @@ export async function handleBuildComplete({
onMatchHeaders: [], onMatchHeaders: [],
rewrites, rewrites,
restrictedRedirectPaths: [], restrictedRedirectPaths: [],
isAppPPREnabled: config.cacheComponents, isAppCacheComponentsEnabled: config.cacheComponents,
}).routesManifest.rsc, }).routesManifest.rsc,
}, },
outputs, outputs,
......
...@@ -13,7 +13,6 @@ import { discoverRoutes } from '../route-discovery' ...@@ -13,7 +13,6 @@ import { discoverRoutes } from '../route-discovery'
import { findPagesDir } from '../../lib/find-pages-dir' import { findPagesDir } from '../../lib/find-pages-dir'
import loadCustomRoutes from '../../lib/load-custom-routes' import loadCustomRoutes from '../../lib/load-custom-routes'
import { generateRoutesManifest } from '../generate-routes-manifest' import { generateRoutesManifest } from '../generate-routes-manifest'
import { checkIsAppPPREnabled } from '../../server/lib/experimental/ppr'
import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths' import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
import http from 'node:http' import http from 'node:http'
...@@ -167,7 +166,7 @@ async function collectRoutesForAnalyze( ...@@ -167,7 +166,7 @@ async function collectRoutesForAnalyze(
config.basePath ? `${config.basePath}${pathPrefix}` : pathPrefix config.basePath ? `${config.basePath}${pathPrefix}` : pathPrefix
) )
const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr) const isAppCacheComponentsEnabled = !!config.cacheComponents
// Generate routes manifest // Generate routes manifest
const { routesManifest } = generateRoutesManifest({ const { routesManifest } = generateRoutesManifest({
...@@ -179,7 +178,7 @@ async function collectRoutesForAnalyze( ...@@ -179,7 +178,7 @@ async function collectRoutesForAnalyze(
onMatchHeaders, onMatchHeaders,
rewrites, rewrites,
restrictedRedirectPaths, restrictedRedirectPaths,
isAppPPREnabled, isAppCacheComponentsEnabled,
}) })
return routesManifest.dynamicRoutes return routesManifest.dynamicRoutes
......
...@@ -7,7 +7,6 @@ import type { ProxyMatcher } from './analysis/get-page-static-info' ...@@ -7,7 +7,6 @@ import type { ProxyMatcher } from './analysis/get-page-static-info'
import type { Rewrite } from '../lib/load-custom-routes' import type { Rewrite } from '../lib/load-custom-routes'
import path from 'node:path' import path from 'node:path'
import { needsExperimentalReact } from '../lib/needs-experimental-react' import { needsExperimentalReact } from '../lib/needs-experimental-react'
import { checkIsAppPPREnabled } from '../server/lib/experimental/ppr'
import { import {
getNextConfigEnv, getNextConfigEnv,
getNextPublicEnvironmentVariables, getNextPublicEnvironmentVariables,
...@@ -120,7 +119,6 @@ export function getDefineEnv({ ...@@ -120,7 +119,6 @@ export function getDefineEnv({
const nextPublicEnv = getNextPublicEnvironmentVariables() const nextPublicEnv = getNextPublicEnvironmentVariables()
const nextConfigEnv = getNextConfigEnv(config) const nextConfigEnv = getNextConfigEnv(config)
const isPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)
const isCacheComponentsEnabled = !!config.cacheComponents const isCacheComponentsEnabled = !!config.cacheComponents
const isUseCacheEnabled = !!config.experimental.useCache const isUseCacheEnabled = !!config.experimental.useCache
...@@ -170,7 +168,6 @@ export function getDefineEnv({ ...@@ -170,7 +168,6 @@ export function getDefineEnv({
'process.env.__NEXT_APP_NEW_SCROLL_HANDLER': Boolean( 'process.env.__NEXT_APP_NEW_SCROLL_HANDLER': Boolean(
config.experimental.appNewScrollHandler config.experimental.appNewScrollHandler
), ),
'process.env.__NEXT_PPR': isPPREnabled,
'process.env.__NEXT_CACHE_COMPONENTS': isCacheComponentsEnabled, 'process.env.__NEXT_CACHE_COMPONENTS': isCacheComponentsEnabled,
'process.env.__NEXT_INSTANT_NAV_TOGGLE': 'process.env.__NEXT_INSTANT_NAV_TOGGLE':
!!config.experimental.instantNavigationDevToolsToggle, !!config.experimental.instantNavigationDevToolsToggle,
......
...@@ -34,7 +34,7 @@ export interface GenerateRoutesManifestOptions { ...@@ -34,7 +34,7 @@ export interface GenerateRoutesManifestOptions {
onMatchHeaders: CustomRoutes['headers'] onMatchHeaders: CustomRoutes['headers']
rewrites: CustomRoutes['rewrites'] rewrites: CustomRoutes['rewrites']
restrictedRedirectPaths: string[] restrictedRedirectPaths: string[]
isAppPPREnabled: boolean isAppCacheComponentsEnabled: boolean
appType: 'pages' | 'app' | 'hybrid' appType: 'pages' | 'app' | 'hybrid'
deploymentId?: string deploymentId?: string
} }
...@@ -61,7 +61,7 @@ export function generateRoutesManifest( ...@@ -61,7 +61,7 @@ export function generateRoutesManifest(
onMatchHeaders, onMatchHeaders,
rewrites, rewrites,
restrictedRedirectPaths, restrictedRedirectPaths,
isAppPPREnabled, isAppCacheComponentsEnabled,
appType, appType,
deploymentId, deploymentId,
} = options } = options
...@@ -132,7 +132,8 @@ export function generateRoutesManifest( ...@@ -132,7 +132,8 @@ export function generateRoutesManifest(
prefetchSegmentDirSuffix: RSC_SEGMENTS_DIR_SUFFIX, prefetchSegmentDirSuffix: RSC_SEGMENTS_DIR_SUFFIX,
clientParamParsing: config.cacheComponents ?? false, clientParamParsing: config.cacheComponents ?? false,
clientParamParsingOrigins: config.experimental.clientParamParsingOrigins, clientParamParsingOrigins: config.experimental.clientParamParsingOrigins,
dynamicRSCPrerender: isAppPPREnabled && config.cacheComponents === true, dynamicRSCPrerender:
isAppCacheComponentsEnabled && config.cacheComponents === true,
}, },
rewriteHeaders: { rewriteHeaders: {
pathHeader: NEXT_REWRITTEN_PATH_HEADER, pathHeader: NEXT_REWRITTEN_PATH_HEADER,
...@@ -140,7 +141,7 @@ export function generateRoutesManifest( ...@@ -140,7 +141,7 @@ export function generateRoutesManifest(
}, },
skipProxyUrlNormalize: config.skipProxyUrlNormalize, skipProxyUrlNormalize: config.skipProxyUrlNormalize,
deploymentId: deploymentId || undefined, deploymentId: deploymentId || undefined,
ppr: isAppPPREnabled ppr: isAppCacheComponentsEnabled
? { ? {
chain: { chain: {
headers: { headers: {
......
...@@ -185,10 +185,6 @@ import { traceMemoryUsage } from '../lib/memory/trace' ...@@ -185,10 +185,6 @@ import { traceMemoryUsage } from '../lib/memory/trace'
import { generateEncryptionKeyBase64 } from '../server/app-render/encryption-utils-server' import { generateEncryptionKeyBase64 } from '../server/app-render/encryption-utils-server'
import type { DeepReadonly } from '../shared/lib/deep-readonly' import type { DeepReadonly } from '../shared/lib/deep-readonly'
import uploadTrace from '../trace/upload-trace' import uploadTrace from '../trace/upload-trace'
import {
checkIsAppPPREnabled,
checkIsRoutePPREnabled,
} from '../server/lib/experimental/ppr'
import { FallbackMode, fallbackModeToFallbackField } from '../lib/fallback' import { FallbackMode, fallbackModeToFallbackField } from '../lib/fallback'
import { RenderingMode } from './rendering-mode' import { RenderingMode } from './rendering-mode'
import { InvariantError } from '../shared/lib/invariant-error' import { InvariantError } from '../shared/lib/invariant-error'
...@@ -1492,8 +1488,6 @@ export default async function build( ...@@ -1492,8 +1488,6 @@ export default async function build(
const isAuthInterruptsEnabled = Boolean( const isAuthInterruptsEnabled = Boolean(
config.experimental.authInterrupts config.experimental.authInterrupts
) )
const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)
const routesManifestPath = path.join(distDir, ROUTES_MANIFEST) const routesManifestPath = path.join(distDir, ROUTES_MANIFEST)
// Generate the routes manifest using the extracted helper // Generate the routes manifest using the extracted helper
...@@ -1509,7 +1503,7 @@ export default async function build( ...@@ -1509,7 +1503,7 @@ export default async function build(
onMatchHeaders, onMatchHeaders,
rewrites, rewrites,
restrictedRedirectPaths, restrictedRedirectPaths,
isAppPPREnabled, isAppCacheComponentsEnabled,
deploymentId: config.deploymentId, deploymentId: config.deploymentId,
}) })
) )
...@@ -2062,7 +2056,6 @@ export default async function build( ...@@ -2062,7 +2056,6 @@ export default async function build(
locales: config.i18n?.locales, locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale, defaultLocale: config.i18n?.defaultLocale,
nextConfigOutput: config.output, nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
cacheLifeProfiles: config.cacheLife, cacheLifeProfiles: config.cacheLife,
buildId, buildId,
clientAssetToken: clientAssetToken:
...@@ -2289,7 +2282,6 @@ export default async function build( ...@@ -2289,7 +2282,6 @@ export default async function build(
: config.experimental.isrFlushToDisk, : config.experimental.isrFlushToDisk,
cacheMaxMemorySize: config.cacheMaxMemorySize, cacheMaxMemorySize: config.cacheMaxMemorySize,
nextConfigOutput: config.output, nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
cacheLifeProfiles: config.cacheLife, cacheLifeProfiles: config.cacheLife,
buildId, buildId,
clientAssetToken: clientAssetToken:
...@@ -2694,7 +2686,7 @@ export default async function build( ...@@ -2694,7 +2686,7 @@ export default async function build(
}, },
{ {
featureName: 'experimental/ppr', featureName: 'experimental/ppr',
invocationCount: config.experimental.ppr ? 1 : 0, invocationCount: config.cacheComponents ? 1 : 0,
}, },
{ {
featureName: 'turbopackFileSystemCache', featureName: 'turbopackFileSystemCache',
...@@ -2880,9 +2872,8 @@ export default async function build( ...@@ -2880,9 +2872,8 @@ export default async function build(
const appConfig = appDefaultConfigs.get(originalAppPath) const appConfig = appDefaultConfigs.get(originalAppPath)
const isDynamicError = appConfig?.dynamic === 'error' const isDynamicError = appConfig?.dynamic === 'error'
const isRoutePPREnabled: boolean = appConfig const isRoutePPREnabled: boolean =
? checkIsRoutePPREnabled(config.experimental.ppr) !!appConfig && isAppCacheComponentsEnabled
: false
routes.forEach((route) => { routes.forEach((route) => {
// If the route has any dynamic root segments, we need to skip // If the route has any dynamic root segments, we need to skip
...@@ -3076,8 +3067,7 @@ export default async function build( ...@@ -3076,8 +3067,7 @@ export default async function build(
// When this is an app page and PPR is enabled, the route supports // When this is an app page and PPR is enabled, the route supports
// partial pre-rendering. // partial pre-rendering.
const isRoutePPREnabled: true | undefined = const isRoutePPREnabled: true | undefined =
!isAppRouteHandler && !isAppRouteHandler && isAppCacheComponentsEnabled
checkIsRoutePPREnabled(config.experimental.ppr)
? true ? true
: undefined : undefined
...@@ -3217,7 +3207,7 @@ export default async function build( ...@@ -3217,7 +3207,7 @@ export default async function build(
prerenderManifest.routes[route.pathname] = { prerenderManifest.routes[route.pathname] = {
initialStatus: status, initialStatus: status,
initialHeaders: meta.headers, initialHeaders: meta.headers,
renderingMode: isAppPPREnabled renderingMode: isAppCacheComponentsEnabled
? isRoutePPREnabled ? isRoutePPREnabled
? RenderingMode.PARTIALLY_STATIC ? RenderingMode.PARTIALLY_STATIC
: RenderingMode.STATIC : RenderingMode.STATIC
...@@ -3301,7 +3291,7 @@ export default async function build( ...@@ -3301,7 +3291,7 @@ export default async function build(
let dynamicRoute = routesManifest.dynamicRoutes.find( let dynamicRoute = routesManifest.dynamicRoutes.find(
(r) => r.page === route.pathname (r) => r.page === route.pathname
) )
if (!isAppRouteHandler && isAppPPREnabled) { if (!isAppRouteHandler && isAppCacheComponentsEnabled) {
// If the dynamic route wasn't found, then we need to create // If the dynamic route wasn't found, then we need to create
// it. This ensures that for each fallback shell there's an // it. This ensures that for each fallback shell there's an
// entry in the app routes manifest which enables routing for // entry in the app routes manifest which enables routing for
...@@ -3404,7 +3394,7 @@ export default async function build( ...@@ -3404,7 +3394,7 @@ export default async function build(
prerenderManifest.dynamicRoutes[route.pathname] = { prerenderManifest.dynamicRoutes[route.pathname] = {
experimentalPPR: isRoutePPREnabled, experimentalPPR: isRoutePPREnabled,
renderingMode: isAppPPREnabled renderingMode: isAppCacheComponentsEnabled
? isRoutePPREnabled ? isRoutePPREnabled
? RenderingMode.PARTIALLY_STATIC ? RenderingMode.PARTIALLY_STATIC
: RenderingMode.STATIC : RenderingMode.STATIC
......
...@@ -20,7 +20,6 @@ import { BaseServerSpan } from '../../server/lib/trace/constants' ...@@ -20,7 +20,6 @@ import { BaseServerSpan } from '../../server/lib/trace/constants'
import { interopDefault } from '../../server/app-render/interop-default' import { interopDefault } from '../../server/app-render/interop-default'
import { stripFlightHeaders } from '../../server/app-render/strip-flight-headers' import { stripFlightHeaders } from '../../server/app-render/strip-flight-headers'
import { NodeNextRequest, NodeNextResponse } from '../../server/base-http/node' import { NodeNextRequest, NodeNextResponse } from '../../server/base-http/node'
import { checkIsAppPPREnabled } from '../../server/lib/experimental/ppr'
import { import {
getFallbackRouteParams, getFallbackRouteParams,
createOpaqueFallbackRouteParams, createOpaqueFallbackRouteParams,
...@@ -100,7 +99,6 @@ import * as entryBase from '../../server/app-render/entry-base' with { 'turbopac ...@@ -100,7 +99,6 @@ import * as entryBase from '../../server/app-render/entry-base' with { 'turbopac
import { RedirectStatusCode } from '../../client/components/redirect-status-code' import { RedirectStatusCode } from '../../client/components/redirect-status-code'
import { InvariantError } from '../../shared/lib/invariant-error' import { InvariantError } from '../../shared/lib/invariant-error'
import { scheduleOnNextTick } from '../../lib/scheduler' import { scheduleOnNextTick } from '../../lib/scheduler'
import { isInterceptionRouteAppPath } from '../../shared/lib/router/utils/interception-routes'
export * from '../../server/app-render/entry-base' with { 'turbopack-transition': 'next-server-utility' } export * from '../../server/app-render/entry-base' with { 'turbopack-transition': 'next-server-utility' }
...@@ -195,16 +193,8 @@ export async function handler( ...@@ -195,16 +193,8 @@ export async function handler(
// We use the resolvedPathname instead of the parsedUrl.pathname because it // We use the resolvedPathname instead of the parsedUrl.pathname because it
// is not rewritten as resolvedPathname is. This will ensure that the correct // is not rewritten as resolvedPathname is. This will ensure that the correct
// prerender info is used instead of using the original pathname as the // prerender info is used instead of using the original pathname as the
// source. If however PPR is enabled and cacheComponents is disabled, we // source.
// treat the pathname as dynamic. Currently, there's a bug in the PPR const prerenderInfo = routeModule.match(resolvedPathname, prerenderManifest)
// implementation that incorrectly leaves %%drp placeholders in the output of
// parallel routes. This is addressed with cacheComponents.
const prerenderInfo =
nextConfig.experimental.ppr &&
!nextConfig.cacheComponents &&
isInterceptionRouteAppPath(resolvedPathname)
? null
: routeModule.match(resolvedPathname, prerenderManifest)
const isPrerendered = !!prerenderManifest.routes[resolvedPathname] const isPrerendered = !!prerenderManifest.routes[resolvedPathname]
...@@ -228,12 +218,10 @@ export async function handler( ...@@ -228,12 +218,10 @@ export async function handler(
const isPossibleServerAction = getIsPossibleServerAction(req) const isPossibleServerAction = getIsPossibleServerAction(req)
/** /**
* If the route being rendered is an app page, and the ppr feature has been * If the route being rendered is an app page, and the cacheComponents feature
* enabled, then the given route _could_ support PPR. * has been enabled, then the given route _could_ support PPR.
*/ */
const couldSupportPPR: boolean = checkIsAppPPREnabled( const isAppCacheComponentsEnabled: boolean = !!nextConfig.cacheComponents
nextConfig.experimental.ppr
)
// Stash postponed state for server actions when in minimal mode. // Stash postponed state for server actions when in minimal mode.
// We extract it here so the RDC is available for the re-render after the action completes. // We extract it here so the RDC is available for the re-render after the action completes.
...@@ -241,7 +229,7 @@ export async function handler( ...@@ -241,7 +229,7 @@ export async function handler(
if ( if (
!getRequestMeta(req, 'postponed') && !getRequestMeta(req, 'postponed') &&
isMinimalMode && isMinimalMode &&
couldSupportPPR && isAppCacheComponentsEnabled &&
isPossibleServerAction && isPossibleServerAction &&
resumeStateLengthHeader && resumeStateLengthHeader &&
typeof resumeStateLengthHeader === 'string' typeof resumeStateLengthHeader === 'string'
...@@ -305,7 +293,7 @@ export async function handler( ...@@ -305,7 +293,7 @@ export async function handler(
if ( if (
!getRequestMeta(req, 'postponed') && !getRequestMeta(req, 'postponed') &&
couldSupportPPR && isAppCacheComponentsEnabled &&
req.headers[NEXT_RESUME_HEADER] === '1' && req.headers[NEXT_RESUME_HEADER] === '1' &&
req.method === 'POST' req.method === 'POST'
) { ) {
...@@ -332,7 +320,7 @@ export async function handler( ...@@ -332,7 +320,7 @@ export async function handler(
const hasDebugStaticShellQuery = const hasDebugStaticShellQuery =
process.env.__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING === '1' && process.env.__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING === '1' &&
typeof query.__nextppronly !== 'undefined' && typeof query.__nextppronly !== 'undefined' &&
couldSupportPPR isAppCacheComponentsEnabled
// When enabled, this will allow the use of the `?__nextppronly` query // When enabled, this will allow the use of the `?__nextppronly` query
// to enable debugging of the fallback shell. // to enable debugging of the fallback shell.
...@@ -354,7 +342,7 @@ export async function handler( ...@@ -354,7 +342,7 @@ export async function handler(
// with blocking happening on the client side. // with blocking happening on the client side.
const isInstantNavigationTest = const isInstantNavigationTest =
exposeTestingApi && exposeTestingApi &&
couldSupportPPR && isAppCacheComponentsEnabled &&
(req.headers[NEXT_INSTANT_PREFETCH_HEADER] === '1' || (req.headers[NEXT_INSTANT_PREFETCH_HEADER] === '1' ||
(req.headers[RSC_HEADER] === undefined && (req.headers[RSC_HEADER] === undefined &&
typeof req.headers.cookie === 'string' && typeof req.headers.cookie === 'string' &&
...@@ -363,7 +351,7 @@ export async function handler( ...@@ -363,7 +351,7 @@ export async function handler(
// This page supports PPR if it is marked as being `PARTIALLY_STATIC` in the // This page supports PPR if it is marked as being `PARTIALLY_STATIC` in the
// prerender manifest and this is an app page. // prerender manifest and this is an app page.
const isRoutePPREnabled: boolean = const isRoutePPREnabled: boolean =
couldSupportPPR && isAppCacheComponentsEnabled &&
(( ((
prerenderManifest.routes[normalizedSrcPage] ?? prerenderManifest.routes[normalizedSrcPage] ??
prerenderManifest.dynamicRoutes[normalizedSrcPage] prerenderManifest.dynamicRoutes[normalizedSrcPage]
......
...@@ -2,8 +2,6 @@ import type { ...@@ -2,8 +2,6 @@ import type {
NextConfigComplete, NextConfigComplete,
NextConfigRuntime, NextConfigRuntime,
} from '../server/config-shared' } from '../server/config-shared'
import type { ExperimentalPPRConfig } from '../server/lib/experimental/ppr'
import { checkIsRoutePPREnabled } from '../server/lib/experimental/ppr'
import type { AssetBinding } from './webpack/loaders/get-module-build-info' import type { AssetBinding } from './webpack/loaders/get-module-build-info'
import type { ServerRuntime } from '../types' import type { ServerRuntime } from '../types'
import type { BuildManifest } from '../server/get-page-files' import type { BuildManifest } from '../server/get-page-files'
...@@ -666,7 +664,6 @@ export async function isPageStatic({ ...@@ -666,7 +664,6 @@ export async function isPageStatic({
cacheHandler, cacheHandler,
cacheHandlers, cacheHandlers,
cacheLifeProfiles, cacheLifeProfiles,
pprConfig,
buildId, buildId,
clientAssetToken, clientAssetToken,
sriEnabled, sriEnabled,
...@@ -693,7 +690,6 @@ export async function isPageStatic({ ...@@ -693,7 +690,6 @@ export async function isPageStatic({
[profile: string]: import('../server/use-cache/cache-life').CacheLife [profile: string]: import('../server/use-cache/cache-life').CacheLife
} }
nextConfigOutput: 'standalone' | 'export' | undefined nextConfigOutput: 'standalone' | 'export' | undefined
pprConfig: ExperimentalPPRConfig | undefined
buildId: string buildId: string
clientAssetToken: string clientAssetToken: string
sriEnabled: boolean sriEnabled: boolean
...@@ -820,12 +816,10 @@ export async function isPageStatic({ ...@@ -820,12 +816,10 @@ export async function isPageStatic({
rootParamKeys = collectRootParamKeys(routeModule) rootParamKeys = collectRootParamKeys(routeModule)
// A page supports partial prerendering if it is an app page and either // A page supports partial prerendering if it is an app page and
// the whole app has PPR enabled or this page has PPR enabled when we're // cacheComponents is enabled.
// in incremental mode.
isRoutePPREnabled = isRoutePPREnabled =
routeModule.definition.kind === RouteKind.APP_PAGE && routeModule.definition.kind === RouteKind.APP_PAGE && cacheComponents
checkIsRoutePPREnabled(pprConfig)
// If force dynamic was set and we don't have PPR enabled, then set the // If force dynamic was set and we don't have PPR enabled, then set the
// revalidate to 0. // revalidate to 0.
......
...@@ -167,15 +167,11 @@ export async function fetchServerResponse( ...@@ -167,15 +167,11 @@ export async function fetchServerResponse(
// Typically, during a navigation, we decode the response using Flight's // Typically, during a navigation, we decode the response using Flight's
// `createFromFetch` API, which accepts a `fetch` promise. // `createFromFetch` API, which accepts a `fetch` promise.
// TODO: Remove this check once the old PPR flag is removed
const isLegacyPPR =
process.env.__NEXT_PPR && !process.env.__NEXT_CACHE_COMPONENTS
const shouldImmediatelyDecode = !isLegacyPPR
const res = await createFetch<NavigationFlightResponse>( const res = await createFetch<NavigationFlightResponse>(
url, url,
headers, headers,
'auto', 'auto',
shouldImmediatelyDecode true
) )
const responseUrl = urlToUrlWithoutFlightMarker(new URL(res.url)) const responseUrl = urlToUrlWithoutFlightMarker(new URL(res.url))
......
...@@ -856,7 +856,7 @@ async function exportAppImpl( ...@@ -856,7 +856,7 @@ async function exportAppImpl(
} }
// Export mode provide static outputs that are not compatible with PPR mode. // Export mode provide static outputs that are not compatible with PPR mode.
if (!options.buildExport && nextConfig.experimental.ppr) { if (!options.buildExport && nextConfig.cacheComponents) {
// TODO: add message // TODO: add message
throw new Error('Invariant: PPR cannot be enabled in export mode') throw new Error('Invariant: PPR cannot be enabled in export mode')
} }
......
...@@ -132,7 +132,6 @@ import { toRoute } from './lib/to-route' ...@@ -132,7 +132,6 @@ import { toRoute } from './lib/to-route'
import type { DeepReadonly } from '../shared/lib/deep-readonly' import type { DeepReadonly } from '../shared/lib/deep-readonly'
import { isNodeNextRequest, isNodeNextResponse } from './base-http/helpers' import { isNodeNextRequest, isNodeNextResponse } from './base-http/helpers'
import { patchSetHeaderWithCookieSupport } from './lib/patch-set-header' import { patchSetHeaderWithCookieSupport } from './lib/patch-set-header'
import { checkIsAppPPREnabled } from './lib/experimental/ppr'
import { import {
getBuiltinRequestContext, getBuiltinRequestContext,
type WaitUntil, type WaitUntil,
...@@ -427,7 +426,7 @@ export default abstract class Server< ...@@ -427,7 +426,7 @@ export default abstract class Server<
readonly data: NextDataPathnameNormalizer | undefined readonly data: NextDataPathnameNormalizer | undefined
} }
private readonly isAppPPREnabled: boolean private readonly isCacheComponentsEnabled: boolean
/** /**
* This is used to persist cache scopes across * This is used to persist cache scopes across
...@@ -513,9 +512,8 @@ export default abstract class Server< ...@@ -513,9 +512,8 @@ export default abstract class Server<
this.enabledDirectories = this.getEnabledDirectories(dev) this.enabledDirectories = this.getEnabledDirectories(dev)
this.isAppPPREnabled = this.isCacheComponentsEnabled =
this.enabledDirectories.app && this.enabledDirectories.app && !!this.nextConfig.cacheComponents
checkIsAppPPREnabled(this.nextConfig.experimental.ppr)
this.normalizers = { this.normalizers = {
// We should normalize the pathname from the RSC prefix only in minimal // We should normalize the pathname from the RSC prefix only in minimal
...@@ -1083,7 +1081,7 @@ export default abstract class Server< ...@@ -1083,7 +1081,7 @@ export default abstract class Server<
// It's important to execute the following block even it the request // It's important to execute the following block even it the request
// matches a pages data route from above. // matches a pages data route from above.
if ( if (
this.isAppPPREnabled && this.isCacheComponentsEnabled &&
this.minimalMode && this.minimalMode &&
req.headers[NEXT_RESUME_HEADER] === '1' && req.headers[NEXT_RESUME_HEADER] === '1' &&
req.method === 'POST' req.method === 'POST'
...@@ -2194,7 +2192,7 @@ export default abstract class Server< ...@@ -2194,7 +2192,7 @@ export default abstract class Server<
* enabled, then the given route _could_ support PPR. * enabled, then the given route _could_ support PPR.
*/ */
const couldSupportPPR: boolean = const couldSupportPPR: boolean =
this.isAppPPREnabled && this.isCacheComponentsEnabled &&
typeof routeModule !== 'undefined' && typeof routeModule !== 'undefined' &&
isAppPageRouteModule(routeModule) isAppPageRouteModule(routeModule)
......
...@@ -11,7 +11,6 @@ import type { WEB_VITALS } from '../shared/lib/utils' ...@@ -11,7 +11,6 @@ import type { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta' import type { NextParsedUrlQuery } from './request-meta'
import type { SizeLimit } from '../types' import type { SizeLimit } from '../types'
import type { SupportedTestRunners } from '../cli/next-test' import type { SupportedTestRunners } from '../cli/next-test'
import type { ExperimentalPPRConfig } from './lib/experimental/ppr'
import { INFINITE_CACHE } from '../lib/constants' import { INFINITE_CACHE } from '../lib/constants'
import { isStableBuild } from '../shared/lib/errors/canary-only-config-error' import { isStableBuild } from '../shared/lib/errors/canary-only-config-error'
import type { FallbackRouteParam } from '../build/static-paths/types' import type { FallbackRouteParam } from '../build/static-paths/types'
...@@ -692,7 +691,7 @@ export interface ExperimentalConfig { ...@@ -692,7 +691,7 @@ export interface ExperimentalConfig {
* @deprecated This configuration option has been merged into `cacheComponents`. * @deprecated This configuration option has been merged into `cacheComponents`.
* The Partial Prerendering feature is still available via `cacheComponents`. * The Partial Prerendering feature is still available via `cacheComponents`.
*/ */
ppr?: ExperimentalPPRConfig ppr?: boolean | 'incremental'
/** /**
* Enables experimental taint APIs in React. * Enables experimental taint APIs in React.
......
...@@ -1396,9 +1396,6 @@ function assignDefaultsAndValidate( ...@@ -1396,9 +1396,6 @@ function assignDefaultsAndValidate(
} }
if (result.cacheComponents) { if (result.cacheComponents) {
// TODO: remove once we've finished migrating internally to cacheComponents.
result.experimental.ppr = true
// Prerender sourcemaps are enabled by default when using cacheComponents, unless explicitly disabled. // Prerender sourcemaps are enabled by default when using cacheComponents, unless explicitly disabled.
if (result.enablePrerenderSourceMaps === undefined) { if (result.enablePrerenderSourceMaps === undefined) {
result.enablePrerenderSourceMaps = true result.enablePrerenderSourceMaps = true
......
...@@ -798,7 +798,6 @@ export default class DevServer extends Server { ...@@ -798,7 +798,6 @@ export default class DevServer extends Server {
distDir: this.distDir, distDir: this.distDir,
pathname, pathname,
config: { config: {
pprConfig: this.nextConfig.experimental.ppr,
configFileName, configFileName,
cacheComponents: Boolean(this.nextConfig.cacheComponents), cacheComponents: Boolean(this.nextConfig.cacheComponents),
}, },
......
...@@ -17,10 +17,6 @@ import { loadComponents } from '../load-components' ...@@ -17,10 +17,6 @@ import { loadComponents } from '../load-components'
import { setHttpClientAndAgentOptions } from '../setup-http-agent-env' import { setHttpClientAndAgentOptions } from '../setup-http-agent-env'
import type { IncrementalCache } from '../lib/incremental-cache' import type { IncrementalCache } from '../lib/incremental-cache'
import { isAppPageRouteModule } from '../route-modules/checks' import { isAppPageRouteModule } from '../route-modules/checks'
import {
checkIsRoutePPREnabled,
type ExperimentalPPRConfig,
} from '../lib/experimental/ppr'
import { InvariantError } from '../../shared/lib/invariant-error' import { InvariantError } from '../../shared/lib/invariant-error'
import { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys' import { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys'
import { buildAppStaticPaths } from '../../build/static-paths/app' import { buildAppStaticPaths } from '../../build/static-paths/app'
...@@ -29,7 +25,6 @@ import { createIncrementalCache } from '../../export/helpers/create-incremental- ...@@ -29,7 +25,6 @@ import { createIncrementalCache } from '../../export/helpers/create-incremental-
import { parseAppRoute } from '../../shared/lib/router/routes/app' import { parseAppRoute } from '../../shared/lib/router/routes/app'
type RuntimeConfig = { type RuntimeConfig = {
pprConfig: ExperimentalPPRConfig | undefined
configFileName: string configFileName: string
cacheComponents: boolean cacheComponents: boolean
} }
...@@ -126,8 +121,7 @@ export async function loadStaticPaths({ ...@@ -126,8 +121,7 @@ export async function loadStaticPaths({
} }
const isRoutePPREnabled = const isRoutePPREnabled =
isAppPageRouteModule(routeModule) && isAppPageRouteModule(routeModule) && config.cacheComponents
checkIsRoutePPREnabled(config.pprConfig)
const rootParamKeys = collectRootParamKeys(routeModule) const rootParamKeys = collectRootParamKeys(routeModule)
......
/**
* If set to `incremental`, only those leaf pages that export
* `experimental_ppr = true` will have partial prerendering enabled. If any
* page exports this value as `false` or does not export it at all will not
* have partial prerendering enabled. If set to a boolean, the options for
* `experimental_ppr` will be ignored.
*/
export type ExperimentalPPRConfig = boolean | 'incremental'
/**
* Returns true if partial prerendering is enabled for the application. It does
* not tell you if a given route has PPR enabled, as that requires analysis of
* the route's configuration.
*
* @see {@link checkIsRoutePPREnabled} - for checking if a specific route has PPR enabled.
*/
export function checkIsAppPPREnabled(
config: ExperimentalPPRConfig | undefined
): boolean {
// If the config is undefined, partial prerendering is disabled.
if (typeof config === 'undefined') return false
// If the config is a boolean, use it directly.
if (typeof config === 'boolean') return config
// If the config is a string, it must be 'incremental' to enable partial
// prerendering.
if (config === 'incremental') return true
return false
}
/**
* Returns true if partial prerendering is supported for the current page with
* the provided app configuration. If the application doesn't have partial
* prerendering enabled, this function will always return false. If you want to
* check if the application has partial prerendering enabled
*
* @see {@link checkIsAppPPREnabled} for checking if the application has PPR enabled.
*/
export function checkIsRoutePPREnabled(
config: ExperimentalPPRConfig | undefined
): boolean {
// If the config is undefined, partial prerendering is disabled.
if (typeof config === 'undefined') return false
// If the config is a boolean, use it directly.
if (typeof config === 'boolean') return config
return false
}
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