File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
test/e2e/app-dir/static-export Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -2141,15 +2141,18 @@ export default async function build(
2141
2141
if ( appConfig . revalidate !== 0 ) {
2142
2142
const isDynamic = isDynamicRoute ( page )
2143
2143
const hasGenerateStaticParams =
2144
- workerResult . prerenderedRoutes !== undefined
2144
+ workerResult . prerenderedRoutes &&
2145
+ workerResult . prerenderedRoutes . length > 0
2145
2146
2146
2147
if (
2147
2148
config . output === 'export' &&
2148
2149
isDynamic &&
2149
2150
! hasGenerateStaticParams
2150
2151
) {
2151
2152
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.`
2153
2156
)
2154
2157
}
2155
2158
Original file line number Diff line number Diff line change 1
1
import { nextTestSetup } from 'e2e-utils'
2
2
3
3
describe ( 'app-dir generateStaticParams - next export' , ( ) => {
4
- const { next, skipped, isNextStart } = nextTestSetup ( {
4
+ const { next, skipped } = nextTestSetup ( {
5
5
files : __dirname ,
6
6
skipDeployment : true ,
7
7
skipStart : true ,
8
8
} )
9
9
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 ( ) => {
11
11
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
+ )
13
17
} )
14
18
15
- it ( 'should when `generateStaticParams` is not defined' , async ( ) => {
19
+ it ( 'should error when `generateStaticParams` is not defined' , async ( ) => {
16
20
await next . patchFile (
17
21
'app/[slug]/page.js' ,
18
22
`
@@ -24,5 +28,8 @@ export default function Page({ params }) {
24
28
25
29
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
+ )
27
34
} )
28
35
} )
You can’t perform that action at this time.
0 commit comments