Unverified Commit c0bf4b6f authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

partial fallbacks: gate behind experimental flag (#91123)

This puts the partial fallback upgrading feature introduced in
https://github.com/vercel/next.js/pull/89063 behind a flag to make it
easier to test the rollout/eventual stabilization in isolation.
parent 5e11e677
...@@ -1589,7 +1589,10 @@ export async function handleBuildComplete({ ...@@ -1589,7 +1589,10 @@ export async function handleBuildComplete({
(item) => item.page === dynamicRoute (item) => item.page === dynamicRoute
)?.routeKeys || {} )?.routeKeys || {}
) )
const partialFallbacksEnabled =
config.experimental.partialFallbacks === true
const partialFallback = const partialFallback =
partialFallbacksEnabled &&
isAppPage && isAppPage &&
renderingMode === RenderingMode.PARTIALLY_STATIC && renderingMode === RenderingMode.PARTIALLY_STATIC &&
typeof fallback === 'string' && typeof fallback === 'string' &&
...@@ -1611,8 +1614,9 @@ export async function handleBuildComplete({ ...@@ -1611,8 +1614,9 @@ export async function handleBuildComplete({
// RSC shell. // RSC shell.
else if (meta.postponed) { else if (meta.postponed) {
// If there's postponed fallback content, we usually collapse to a shared shell (`[]`). // If there's postponed fallback content, we usually collapse to a shared shell (`[]`).
// For partial fallbacks in cache components, keep route allowQuery so // For opt-in partial fallbacks in cache components, keep route
// fallback shells can be upgraded per-param instead of sharing one cache key. // allowQuery so fallback shells can be upgraded per-param instead
// of sharing one cache key.
htmlAllowQuery = htmlAllowQuery =
partialFallback && routesManifest.rsc.clientParamParsing partialFallback && routesManifest.rsc.clientParamParsing
? allowQuery ? allowQuery
......
...@@ -979,6 +979,7 @@ export async function handler( ...@@ -979,6 +979,7 @@ export async function handler(
if ( if (
!isMinimalMode && !isMinimalMode &&
isRoutePPREnabled && isRoutePPREnabled &&
nextConfig.experimental.partialFallbacks === true &&
ssgCacheKey && ssgCacheKey &&
incrementalCache && incrementalCache &&
!isOnDemandRevalidate && !isOnDemandRevalidate &&
......
...@@ -219,6 +219,7 @@ export const experimentalSchema = { ...@@ -219,6 +219,7 @@ export const experimentalSchema = {
caseSensitiveRoutes: z.boolean().optional(), caseSensitiveRoutes: z.boolean().optional(),
clientParamParsingOrigins: z.array(z.string()).optional(), clientParamParsingOrigins: z.array(z.string()).optional(),
cachedNavigations: z.boolean().optional(), cachedNavigations: z.boolean().optional(),
partialFallbacks: z.boolean().optional(),
dynamicOnHover: z.boolean().optional(), dynamicOnHover: z.boolean().optional(),
optimisticRouting: z.boolean().optional(), optimisticRouting: z.boolean().optional(),
varyParams: z.boolean().optional(), varyParams: z.boolean().optional(),
......
...@@ -353,6 +353,11 @@ export interface ExperimentalConfig { ...@@ -353,6 +353,11 @@ export interface ExperimentalConfig {
*/ */
clientParamParsingOrigins?: string[] clientParamParsingOrigins?: string[]
cachedNavigations?: boolean cachedNavigations?: boolean
/**
* Enables partial fallback shells for cache-components routes while the
* feature stabilizes.
*/
partialFallbacks?: boolean
dynamicOnHover?: boolean dynamicOnHover?: boolean
optimisticRouting?: boolean optimisticRouting?: boolean
varyParams?: boolean varyParams?: boolean
...@@ -1648,6 +1653,7 @@ export const defaultConfig = Object.freeze({ ...@@ -1648,6 +1653,7 @@ export const defaultConfig = Object.freeze({
caseSensitiveRoutes: false, caseSensitiveRoutes: false,
clientParamParsingOrigins: undefined, clientParamParsingOrigins: undefined,
cachedNavigations: false, cachedNavigations: false,
partialFallbacks: false,
dynamicOnHover: false, dynamicOnHover: false,
varyParams: false, varyParams: false,
prefetchInlining: false, prefetchInlining: false,
...@@ -1828,6 +1834,7 @@ export interface NextConfigRuntime { ...@@ -1828,6 +1834,7 @@ export interface NextConfigRuntime {
| 'maxPostponedStateSize' | 'maxPostponedStateSize'
| 'devCacheControlNoCache' | 'devCacheControlNoCache'
| 'cachedNavigations' | 'cachedNavigations'
| 'partialFallbacks'
| 'exposeTestingApiInProductionBuild' | 'exposeTestingApiInProductionBuild'
| 'immutableAssetToken' | 'immutableAssetToken'
> & { > & {
...@@ -1898,6 +1905,7 @@ export function getNextConfigRuntime( ...@@ -1898,6 +1905,7 @@ export function getNextConfigRuntime(
maxPostponedStateSize: ex.maxPostponedStateSize, maxPostponedStateSize: ex.maxPostponedStateSize,
devCacheControlNoCache: ex.devCacheControlNoCache, devCacheControlNoCache: ex.devCacheControlNoCache,
cachedNavigations: ex.cachedNavigations, cachedNavigations: ex.cachedNavigations,
partialFallbacks: ex.partialFallbacks,
exposeTestingApiInProductionBuild: ex.exposeTestingApiInProductionBuild, exposeTestingApiInProductionBuild: ex.exposeTestingApiInProductionBuild,
immutableAssetToken: ex.immutableAssetToken, immutableAssetToken: ex.immutableAssetToken,
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: {
partialFallbacks: true,
},
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const nextConfig = { const nextConfig = {
experimental: { experimental: {
useCache: true, useCache: true,
partialFallbacks: true,
}, },
rewrites: async () => { rewrites: async () => {
return { return {
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
*/ */
const nextConfig = { const nextConfig = {
cacheComponents: true, cacheComponents: true,
experimental: {
partialFallbacks: true,
},
} }
module.exports = nextConfig module.exports = nextConfig
...@@ -258,7 +258,6 @@ describe('adapter-config', () => { ...@@ -258,7 +258,6 @@ describe('adapter-config', () => {
const indexPrerender = prerenderOutputs.find( const indexPrerender = prerenderOutputs.find(
(item) => item.pathname === '/docs' (item) => item.pathname === '/docs'
) )
expect(indexPrerender?.fallback?.initialHeaders).toEqual({ expect(indexPrerender?.fallback?.initialHeaders).toEqual({
'content-type': 'text/html; charset=utf-8', 'content-type': 'text/html; charset=utf-8',
vary: 'rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch', vary: 'rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch',
......
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