Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app ISR handling with no generateStaticParams #44787

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,8 @@ export default async function build(
isSsg = true
}
if (
!isDynamicRoute(page) &&
(!isDynamicRoute(page) ||
!workerResult.prerenderRoutes?.length) &&
workerResult.appConfig?.revalidate !== 0
) {
appStaticPaths.set(originalAppPath, [page])
Expand Down Expand Up @@ -2360,6 +2361,8 @@ export default async function build(
let hasDynamicData = appConfig.revalidate === 0

routes.forEach((route) => {
if (isDynamicRoute(page) && route === page) return

let revalidate = exportConfig.initialPageRevalidationMap[route]

if (typeof revalidate === 'undefined') {
Expand Down
5 changes: 4 additions & 1 deletion packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,10 @@ export async function buildAppStaticPaths({
if (!hadGenerateParams) {
return {
paths: undefined,
fallback: undefined,
fallback:
process.env.NODE_ENV === 'production' && isDynamicRoute(page)
? true
: undefined,
encodedPaths: undefined,
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ createNextDescribe(
'dynamic-error.rsc',
'dynamic-error/page.js',
'dynamic-no-gen-params-ssr/[slug]/page.js',
'dynamic-no-gen-params/[slug].html',
'dynamic-no-gen-params/[slug].rsc',
'dynamic-no-gen-params/[slug]/page.js',
'force-static/[slug]/page.js',
'force-static/first.html',
Expand Down Expand Up @@ -201,6 +203,16 @@ createNextDescribe(
fallback: false,
routeRegex: normalizeRegEx('^\\/blog\\/([^\\/]+?)(?:\\/)?$'),
},
'/dynamic-no-gen-params/[slug]': {
dataRoute: '/dynamic-no-gen-params/[slug].rsc',
dataRouteRegex: normalizeRegEx(
'^\\/dynamic\\-no\\-gen\\-params\\/([^\\/]+?)\\.rsc$'
),
fallback: null,
routeRegex: normalizeRegEx(
'^\\/dynamic\\-no\\-gen\\-params\\/([^\\/]+?)(?:\\/)?$'
),
},
'/hooks/use-pathname/[slug]': {
dataRoute: '/hooks/use-pathname/[slug].rsc',
dataRouteRegex: '^\\/hooks\\/use\\-pathname\\/([^\\/]+?)\\.rsc$',
Expand Down