Skip to content

Commit ad48202

Browse files
authored
Ensure force-dynamic is honored during build (#45015)
1 parent 04f2646 commit ad48202

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

packages/next/src/build/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ export async function buildStaticPaths({
10481048
export type AppConfig = {
10491049
revalidate?: number | false
10501050
dynamicParams?: true | false
1051-
dynamic?: 'auto' | 'error' | 'force-static'
1051+
dynamic?: 'auto' | 'error' | 'force-static' | 'force-dynamic'
10521052
fetchCache?: 'force-cache' | 'only-cache'
10531053
preferredRegion?: string
10541054
}
@@ -1354,6 +1354,10 @@ export async function isPageStatic({
13541354
{}
13551355
)
13561356

1357+
if (appConfig.dynamic === 'force-dynamic') {
1358+
appConfig.revalidate = 0
1359+
}
1360+
13571361
if (isDynamicRoute(page)) {
13581362
;({
13591363
paths: prerenderRoutes,

test/e2e/app-dir/app-static/app-static.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ createNextDescribe(
4646
'dynamic-no-gen-params/[slug].html',
4747
'dynamic-no-gen-params/[slug].rsc',
4848
'dynamic-no-gen-params/[slug]/page.js',
49+
'force-dynamic-no-prerender/[id]/page.js',
4950
'force-static/[slug]/page.js',
5051
'force-static/first.html',
5152
'force-static/first.rsc',
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const dynamic = 'force-dynamic'
2+
3+
export default function Page({ params }) {
4+
throw new Error('this should not attempt prerendering with force-dynamic')
5+
}

0 commit comments

Comments
 (0)