Unverified Commit 77662563 authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

Remove deprecated experimental_ppr route-level configuration (#84871)

### What?

Removes the deprecated `experimental_ppr` route-level configuration
option from Next.js.

### Why?

The PPR configuration feature has been deprecated in favor of the cache
components feature flag. The `experimental_ppr` route-level option no
longer has any effect since incremental PPR is not supported with cache
components.

Rather than silently ignoring this configuration, this change ensures
that users receive an explicit error when they attempt to export
`experimental_ppr` from their routes. This provides clear feedback that
the configuration needs to be removed when migrating to the cache
components approach.

### How?

- Removed `experimental_ppr` from the segment config schema and types
(both Rust and TypeScript)
- Updated `checkIsRoutePPREnabled` to no longer accept the `appConfig`
parameter since route-level config is removed
- Added `experimental_ppr` to the list of possibly invalid exports when
cache components are enabled, ensuring users get an error instead of
silent failure
- Removed unused `reduceAppConfig` import that was no longer needed
after these changes
parent 7e11a155
...@@ -89,7 +89,6 @@ pub struct NextSegmentConfig { ...@@ -89,7 +89,6 @@ pub struct NextSegmentConfig {
pub fetch_cache: Option<NextSegmentFetchCache>, pub fetch_cache: Option<NextSegmentFetchCache>,
pub runtime: Option<NextRuntime>, pub runtime: Option<NextRuntime>,
pub preferred_region: Option<Vec<RcStr>>, pub preferred_region: Option<Vec<RcStr>>,
pub experimental_ppr: Option<bool>,
pub middleware_matcher: Option<Vec<MiddlewareMatcherKind>>, pub middleware_matcher: Option<Vec<MiddlewareMatcherKind>>,
/// Whether these exports are defined in the source file. /// Whether these exports are defined in the source file.
...@@ -118,7 +117,6 @@ impl NextSegmentConfig { ...@@ -118,7 +117,6 @@ impl NextSegmentConfig {
fetch_cache, fetch_cache,
runtime, runtime,
preferred_region, preferred_region,
experimental_ppr,
.. ..
} = self; } = self;
*dynamic = dynamic.or(parent.dynamic); *dynamic = dynamic.or(parent.dynamic);
...@@ -127,7 +125,6 @@ impl NextSegmentConfig { ...@@ -127,7 +125,6 @@ impl NextSegmentConfig {
*fetch_cache = fetch_cache.or(parent.fetch_cache); *fetch_cache = fetch_cache.or(parent.fetch_cache);
*runtime = runtime.or(parent.runtime); *runtime = runtime.or(parent.runtime);
*preferred_region = preferred_region.take().or(parent.preferred_region.clone()); *preferred_region = preferred_region.take().or(parent.preferred_region.clone());
*experimental_ppr = experimental_ppr.or(parent.experimental_ppr);
} }
/// Applies a config from a parallel route to this config, returning an /// Applies a config from a parallel route to this config, returning an
...@@ -161,7 +158,6 @@ impl NextSegmentConfig { ...@@ -161,7 +158,6 @@ impl NextSegmentConfig {
fetch_cache, fetch_cache,
runtime, runtime,
preferred_region, preferred_region,
experimental_ppr,
.. ..
} = self; } = self;
merge_parallel(dynamic, &parallel_config.dynamic, "dynamic")?; merge_parallel(dynamic, &parallel_config.dynamic, "dynamic")?;
...@@ -178,11 +174,6 @@ impl NextSegmentConfig { ...@@ -178,11 +174,6 @@ impl NextSegmentConfig {
&parallel_config.preferred_region, &parallel_config.preferred_region,
"preferredRegion", "preferredRegion",
)?; )?;
merge_parallel(
experimental_ppr,
&parallel_config.experimental_ppr,
"experimental_ppr",
)?;
Ok(()) Ok(())
} }
} }
...@@ -930,35 +921,6 @@ async fn parse_config_value( ...@@ -930,35 +921,6 @@ async fn parse_config_value(
"generateStaticParams" => { "generateStaticParams" => {
config.generate_static_params = Some(span); config.generate_static_params = Some(span);
} }
"experimental_ppr" => {
let Some(value) = get_value() else {
return invalid_config(
source,
"experimental_ppr",
span,
rcstr!("It mustn't be reexported."),
None,
IssueSeverity::Error,
)
.await;
};
if matches!(value, JsValue::Constant(ConstantValue::Undefined)) {
return Ok(());
}
let Some(val) = value.as_bool() else {
return invalid_config(
source,
"experimental_ppr",
span,
rcstr!("`experimental_ppr` needs to be a static boolean."),
Some(&value),
IssueSeverity::Error,
)
.await;
};
config.experimental_ppr = Some(val);
}
_ => {} _ => {}
} }
......
...@@ -843,7 +843,8 @@ impl ReactServerComponentValidator { ...@@ -843,7 +843,8 @@ impl ReactServerComponentValidator {
); );
} }
} }
"dynamicParams" | "dynamic" | "fetchCache" | "revalidate" => { "dynamicParams" | "dynamic" | "fetchCache" | "revalidate"
| "experimental_ppr" => {
if self.cache_components_enabled { if self.cache_components_enabled {
possibly_invalid_exports.insert( possibly_invalid_exports.insert(
export_name.clone(), export_name.clone(),
......
...@@ -2912,7 +2912,7 @@ export default async function build( ...@@ -2912,7 +2912,7 @@ export default async function build(
const isDynamicError = appConfig?.dynamic === 'error' const isDynamicError = appConfig?.dynamic === 'error'
const isRoutePPREnabled: boolean = appConfig const isRoutePPREnabled: boolean = appConfig
? checkIsRoutePPREnabled(config.experimental.ppr, appConfig) ? checkIsRoutePPREnabled(config.experimental.ppr)
: false : false
routes.forEach((route) => { routes.forEach((route) => {
...@@ -3105,7 +3105,7 @@ export default async function build( ...@@ -3105,7 +3105,7 @@ export default async function build(
// partial pre-rendering. // partial pre-rendering.
const isRoutePPREnabled: true | undefined = const isRoutePPREnabled: true | undefined =
!isAppRouteHandler && !isAppRouteHandler &&
checkIsRoutePPREnabled(config.experimental.ppr, appConfig) checkIsRoutePPREnabled(config.experimental.ppr)
? true ? true
: undefined : undefined
......
...@@ -135,13 +135,6 @@ const AppSegmentConfigSchema = z.object({ ...@@ -135,13 +135,6 @@ const AppSegmentConfigSchema = z.object({
*/ */
preferredRegion: z.union([z.string(), z.array(z.string())]).optional(), preferredRegion: z.union([z.string(), z.array(z.string())]).optional(),
/**
* Whether the page supports partial prerendering. When true, the page will be
* served using partial prerendering. This setting will only take affect if
* it's enabled via the `experimental.ppr = "incremental"` option.
*/
experimental_ppr: z.boolean().optional(),
/** /**
* The runtime to use for the page. * The runtime to use for the page.
*/ */
...@@ -240,13 +233,6 @@ export type AppSegmentConfig = { ...@@ -240,13 +233,6 @@ export type AppSegmentConfig = {
*/ */
preferredRegion?: string | string[] preferredRegion?: string | string[]
/**
* Whether the page supports partial prerendering. When true, the page will be
* served using partial prerendering. This setting will only take affect if
* it's enabled via the `experimental.ppr = "incremental"` option.
*/
experimental_ppr?: boolean
/** /**
* The runtime to use for the page. * The runtime to use for the page.
*/ */
......
...@@ -823,7 +823,7 @@ export async function isPageStatic({ ...@@ -823,7 +823,7 @@ export async function isPageStatic({
// in incremental mode. // in incremental mode.
isRoutePPREnabled = isRoutePPREnabled =
routeModule.definition.kind === RouteKind.APP_PAGE && routeModule.definition.kind === RouteKind.APP_PAGE &&
checkIsRoutePPREnabled(pprConfig, appConfig) 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.
...@@ -948,7 +948,6 @@ type ReducedAppConfig = Pick< ...@@ -948,7 +948,6 @@ type ReducedAppConfig = Pick<
| 'dynamic' | 'dynamic'
| 'fetchCache' | 'fetchCache'
| 'preferredRegion' | 'preferredRegion'
| 'experimental_ppr'
| 'runtime' | 'runtime'
| 'maxDuration' | 'maxDuration'
> >
...@@ -971,7 +970,6 @@ export function reduceAppConfig( ...@@ -971,7 +970,6 @@ export function reduceAppConfig(
fetchCache, fetchCache,
preferredRegion, preferredRegion,
revalidate, revalidate,
experimental_ppr,
runtime, runtime,
maxDuration, maxDuration,
} = segment.config || {} } = segment.config || {}
...@@ -1004,12 +1002,6 @@ export function reduceAppConfig( ...@@ -1004,12 +1002,6 @@ export function reduceAppConfig(
config.revalidate = revalidate config.revalidate = revalidate
} }
// If partial prerendering has been set, only override it if the current
// value is provided as it's resolved from root layout to leaf page.
if (typeof experimental_ppr !== 'undefined') {
config.experimental_ppr = experimental_ppr
}
if (typeof runtime !== 'undefined') { if (typeof runtime !== 'undefined') {
config.runtime = runtime config.runtime = runtime
} }
......
...@@ -85,7 +85,6 @@ checkFields<Diff<{ ...@@ -85,7 +85,6 @@ checkFields<Diff<{
generateMetadata?: Function generateMetadata?: Function
viewport?: any viewport?: any
generateViewport?: Function generateViewport?: Function
experimental_ppr?: boolean
` `
} }
}, TEntry, ''>>() }, TEntry, ''>>()
......
...@@ -3,7 +3,6 @@ import type { NextConfigComplete } from '../config-shared' ...@@ -3,7 +3,6 @@ import type { NextConfigComplete } from '../config-shared'
import '../require-hook' import '../require-hook'
import '../node-environment' import '../node-environment'
import { reduceAppConfig } from '../../build/utils'
import { collectSegments } from '../../build/segment-config/app/app-segments' import { collectSegments } from '../../build/segment-config/app/app-segments'
import type { StaticPathsResult } from '../../build/static-paths/types' import type { StaticPathsResult } from '../../build/static-paths/types'
import { loadComponents } from '../load-components' import { loadComponents } from '../load-components'
...@@ -114,7 +113,7 @@ export async function loadStaticPaths({ ...@@ -114,7 +113,7 @@ export async function loadStaticPaths({
const isRoutePPREnabled = const isRoutePPREnabled =
isAppPageRouteModule(routeModule) && isAppPageRouteModule(routeModule) &&
checkIsRoutePPREnabled(config.pprConfig, reduceAppConfig(segments)) checkIsRoutePPREnabled(config.pprConfig)
const rootParamKeys = collectRootParamKeys(routeModule) const rootParamKeys = collectRootParamKeys(routeModule)
......
...@@ -40,10 +40,7 @@ export function checkIsAppPPREnabled( ...@@ -40,10 +40,7 @@ export function checkIsAppPPREnabled(
* @see {@link checkIsAppPPREnabled} for checking if the application has PPR enabled. * @see {@link checkIsAppPPREnabled} for checking if the application has PPR enabled.
*/ */
export function checkIsRoutePPREnabled( export function checkIsRoutePPREnabled(
config: ExperimentalPPRConfig | undefined, config: ExperimentalPPRConfig | undefined
appConfig: {
experimental_ppr?: boolean
}
): boolean { ): boolean {
// If the config is undefined, partial prerendering is disabled. // If the config is undefined, partial prerendering is disabled.
if (typeof config === 'undefined') return false if (typeof config === 'undefined') return false
...@@ -51,11 +48,5 @@ export function checkIsRoutePPREnabled( ...@@ -51,11 +48,5 @@ export function checkIsRoutePPREnabled(
// If the config is a boolean, use it directly. // If the config is a boolean, use it directly.
if (typeof config === 'boolean') return config if (typeof config === 'boolean') return config
// If the config is a string, it must be 'incremental' to enable partial
// prerendering.
if (config === 'incremental' && appConfig.experimental_ppr === true) {
return true
}
return false return false
} }
...@@ -145,17 +145,6 @@ const API_DOCS: Record< ...@@ -145,17 +145,6 @@ const API_DOCS: Record<
'`maxDuration` allows you to set max default execution time for your function. If it is not specified, the default value is dependent on your deployment platform and plan.', '`maxDuration` allows you to set max default execution time for your function. If it is not specified, the default value is dependent on your deployment platform and plan.',
link: 'https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration', link: 'https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration',
}, },
experimental_ppr: {
description: `Enables experimental Partial Prerendering (PPR) for this page / layout, when PPR is set to "incremental" mode.`,
link: 'https://nextjs.org/docs/app/api-reference/next-config-js/ppr',
options: {
true: 'Enable PPR for this route',
false: 'Disable PPR for this route',
} satisfies DocsOptionsObject<FullAppSegmentConfig['experimental_ppr']>,
isValid: (value: string) => {
return value === 'true' || value === 'false'
},
},
unstable_prefetch: { unstable_prefetch: {
description: `Specifies the default prefetching behavior for this segment. This configuration is currently under development and will change.`, description: `Specifies the default prefetching behavior for this segment. This configuration is currently under development and will change.`,
link: '(docs coming soon)', link: '(docs coming soon)',
......
import type { Metadata } from 'next' import type { Metadata } from 'next'
export const experimental_ppr = true
export const generateMetadata = async ({ params }): Promise<Metadata> => { export const generateMetadata = async ({ params }): Promise<Metadata> => {
const { slug } = await params const { slug } = await params
return { title: `${slug}` } return { title: `${slug}` }
......
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