8000 show error instead of ignoring · vercel/next.js@de45801 · GitHub
[go: up one dir, main page]

Skip to content

Commit de45801

Browse files
committed
show error instead of ignoring
1 parent 1af1807 commit de45801

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

packages/next/src/build/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,15 +2141,18 @@ export default async function build(
21412141
if (appConfig.revalidate !== 0) {
21422142
const isDynamic = isDynamicRoute(page)
21432143
const hasGenerateStaticParams =
2144-
workerResult.prerenderedRoutes !== undefined
2144+
workerResult.prerenderedRoutes &&
2145+
workerResult.prerenderedRoutes.length > 0
21452146

21462147
if (
21472148
config.output === 'export' &&
21482149
isDynamic &&
21492150
!hasGenerateStaticParams
21502151
) {
21512152
throw new Error(
2152-
`Page "${page}" is missing "generateStaticParams()" so it cannot be used with "output: export" config.`
2153+
workerResult.prerenderedRoutes === undefined
2154+
? `Page "${page}" is missing "generateStaticParams()" so it cannot be used with "output: export" config.`
2155+
: `Page "${page}" returned an empty array in "generateStaticParams()", it is not allowed on "output: export" config.`
21532156
)
21542157
}
21552158

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { nextTestSetup } from 'e2e-utils'
22

33
describe('app-dir generateStaticParams - next export', () => {
4-
const { next, skipped, isNextStart } = nextTestSetup({
4+
const { next, skipped } = nextTestSetup({
55
files: __dirname,
66
skipDeployment: true,
77
skipStart: true,
88
})
99
if (skipped) return
10-
it('should be successful even if `generateStaticParams` return empty array', async () => {
10+
it('should error when `generateStaticParams` returns empty array', async () => {
1111
const out = await next.build()
12-
expect(out.exitCode).toBe(0)
12+
13+
expect(out.exitCode).toBe(1)
14+
expect(out.cliOutput).toInclude(
15+
`returned an empty array in "generateStaticParams()", it is not allowed on "output: export" config.`
16+
)
1317
})
1418

15-
it('should when `generateStaticParams` is not defined', async () => {
19+
it('should error when `generateStaticParams` is not defined', async () => {
1620
await next.patchFile(
1721
'app/[slug]/page.js',
1822
`
@@ -24,5 +28,8 @@ export default function Page({ params }) {
2428

2529
const out = await next.build()
26< 522D /code>30
expect(out.exitCode).toBe(1)
31+
expect(out.cliOutput).toInclude(
32+
`is missing "generateStaticParams()" so it cannot be used with "output: export" config.`
33+
)
2734
})
2835
})

0 commit comments

Comments
 (0)
0