@@ -261,97 +261,14 @@ async function createComponentTreeInternal(
...
@@ -261,97 +261,14 @@ async function createComponentTreeInternal(
})
})
:[]
:[]
letdynamic=layoutOrPageMod?.dynamic
applyDynamicConfig(
layoutOrPageMod,
if(nextConfigOutput==='export'){
workStore,
if(!dynamic||dynamic==='auto'){
nextConfigOutput,
dynamic='error'
experimental.isRoutePPREnabled,
}elseif(dynamic==='force-dynamic'){
segment,
// force-dynamic is always incompatible with 'export'. We must interrupt the build
DynamicServerError
thrownewStaticGenBailoutError(
`Page with \`dynamic = "force-dynamic"\` couldn't be exported. \`output: "export"\` requires all pages be renderable statically because there is no runtime server to dynamically render routes in this output format. Learn more: https://nextjs.org/docs/app/building-your-application/deploying/static-exports`
)
}
}
if(typeofdynamic==='string'){
// the nested most config wins so we only force-static
// if it's configured above any parent that configured
// otherwise
if(dynamic==='error'){
workStore.dynamicShouldError=true
}elseif(dynamic==='force-dynamic'){
workStore.forceDynamic=true
// TODO: (PPR) remove this bailout once PPR is the default
@@ -954,6 +871,101 @@ async function createComponentTreeInternal(
...
@@ -954,6 +871,101 @@ async function createComponentTreeInternal(
}
}
}
}
functionapplyDynamicConfig(
layoutOrPageMod:Record<string,any>|undefined,
workStore:AppRenderContext['workStore'],
nextConfigOutput:string|undefined,
isRoutePPREnabled:boolean|undefined,
segment:string,
DynamicServerError:new(message:string)=>Error
):void{
letdynamic=layoutOrPageMod?.dynamic
if(nextConfigOutput==='export'){
if(!dynamic||dynamic==='auto'){
dynamic='error'
}elseif(dynamic==='force-dynamic'){
thrownewStaticGenBailoutError(
`Page with \`dynamic = "force-dynamic"\` couldn't be exported. \`output: "export"\` requires all pages be renderable statically because there is no runtime server to dynamically render routes in this output format. Learn more: https://nextjs.org/docs/app/building-your-application/deploying/static-exports`
)
}
}
if(typeofdynamic==='string'){
// the nested most config wins so we only force-static
// if it's configured above any parent that configured
// otherwise
if(dynamic==='error'){
workStore.dynamicShouldError=true
}elseif(dynamic==='force-dynamic'){
workStore.forceDynamic=true
// TODO: (PPR) remove this bailout once PPR is the default