Skip to content

Commit

Permalink
Ensure force-dynamic is honored during build (#45015)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Jan 18, 2023
1 parent 04f2646 commit ad48202
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ export async function buildStaticPaths({
export type AppConfig = {
revalidate?: number | false
dynamicParams?: true | false
dynamic?: 'auto' | 'error' | 'force-static'
dynamic?: 'auto' | 'error' | 'force-static' | 'force-dynamic'
fetchCache?: 'force-cache' | 'only-cache'
preferredRegion?: string
}
Expand Down Expand Up @@ -1354,6 +1354,10 @@ export async function isPageStatic({
{}
)

if (appConfig.dynamic === 'force-dynamic') {
appConfig.revalidate = 0
}

if (isDynamicRoute(page)) {
;({
paths: prerenderRoutes,
Expand Down
1 change: 1 addition & 0 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ createNextDescribe(
'dynamic-no-gen-params/[slug].html',
'dynamic-no-gen-params/[slug].rsc',
'dynamic-no-gen-params/[slug]/page.js',
'force-dynamic-no-prerender/[id]/page.js',
'force-static/[slug]/page.js',
'force-static/first.html',
'force-static/first.rsc',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const dynamic = 'force-dynamic'

export default function Page({ params }) {
throw new Error('this should not attempt prerendering with force-dynamic')
}

0 comments on commit ad48202

Please sign in to comment.