@@ -282,17 +282,12 @@ export default async function build(dir: string, conf = null): Promise<void> {
282
282
PAGES_MANIFEST
283
283
)
284
284
285
- const { autoExport } = config . experimental
286
285
const staticPages = new Set < string > ( )
287
286
const invalidPages = new Set < string > ( )
288
287
const pageInfos = new Map < string , PageInfo > ( )
289
- let pagesManifest : any = { }
288
+ const pagesManifest = JSON . parse ( await fsReadFile ( manifestPath , 'utf8' ) )
290
289
let customAppGetInitialProps : boolean | undefined
291
290
292
- if ( autoExport ) {
293
- pagesManifest = JSON . parse ( await fsReadFile ( manifestPath , 'utf8' ) )
294
- }
295
-
296
291
process . env . NEXT_PHASE = PHASE_PRODUCTION_BUILD
297
292
298
293
const staticCheckSema = new Sema ( config . experimental . cpus , {
@@ -324,57 +319,55 @@ export default async function build(dir: string, conf = null): Promise<void> {
324
319
325
320
let isStatic = false
326
321
327
- if ( autoExport ) {
328
- pagesManifest [ page ] = bundleRelative . replace ( / \\ / g, '/' )
322
+ pagesManifest [ page ] = bundleRelative . replace ( / \\ / g, '/' )
329
323
330
- const runtimeEnvConfig = {
331
- publicRuntimeConfig : config . publicRuntimeConfig ,
332
- serverRuntimeConfig : config . serverRuntimeConfig ,
333
- }
334
- const nonReservedPage = ! page . match ( / ^ \/ ( _ a p p | _ e r r o r | _ d o c u m e n t | a p i ) / )
335
-
336
- if ( nonReservedPage && customAppGetInitialProps === undefined ) {
337
- customAppGetInitialProps = hasCustomAppGetInitialProps (
338
- target === 'serverless'
339
- ? serverBundle
340
- : path . join (
341
- distPath ,
342
- SERVER_DIRECTORY ,
343
- `/static/${ buildId } /pages/_app.js`
344
- ) ,
345
- runtimeEnvConfig
324
+ const runtimeEnvConfig = {
325
+ publicRuntimeConfig : config . publicRuntimeConfig ,
326
+ serverRuntimeConfig : config . serverRuntimeConfig ,
327
+ }
328
+ const nonReservedPage = ! page . match ( / ^ \/ ( _ a p p | _ e r r o r | _ d o c u m e n t | a p i ) / )
329
+
330
+ if ( nonReservedPage && customAppGetInitialProps === undefined ) {
331
+ customAppGetInitialProps = hasCustomAppGetInitialProps (
332
+ target === 'serverless'
333
+ ? serverBundle
334
+ : path . join (
335
+ distPath ,
336
+ SERVER_DIRECTORY ,
337
+ `/static/${ buildId } /pages/_app.js`
338
+ ) ,
339
+ runtimeEnvConfig
340
+ )
341
+
342
+ if ( customAppGetInitialProps ) {
343
+ console . warn (
344
+ 'Opting out of automatic exporting due to custom `getInitialProps` in `pages/_app`\n'
346
345
)
346
+ }
347
+ }
347
348
348
- if ( customAppGetInitialProps ) {
349
- console . warn (
350
- 'Opting out of automatic exporting due to custom `getInitialProps` in `pages/_app`\n'
349
+ if ( customAppGetInitialProps === false && nonReservedPage ) {
350
+ try {
351
+ await staticCheckSema . acquire ( )
352
+ const result : any = await new Promise ( ( resolve , reject ) => {
353
+ staticCheckWorkers . default (
354
+ { serverBundle, runtimeEnvConfig } ,
355
+ ( error : Error | null , result : any ) => {
356
+ if ( error ) return reject ( error )
357
+ resolve ( result || { } )
358
+ }
351
359
)
352
- }
353
- }
360
+ } )
361
+ staticCheckSema . release ( )
354
362
355
- if ( customAppGetInitialProps === false && nonReservedPage ) {
356
- try {
357
- await staticCheckSema . acquire ( )
358
- const result : any = await new Promise ( ( resolve , reject ) => {
359
- staticCheckWorkers . default (
360
- { serverBundle, runtimeEnvConfig } ,
361
- ( error : Error | null , result : any ) => {
362
- if ( error ) return reject ( error )
363
- resolve ( result || { } )
364
- }
365
- )
366
- } )
367
- staticCheckSema . release ( )
368
-
369
- if ( result . isStatic ) {
370
- staticPages . add ( page )
371
- isStatic = true
372
- }
373
- } catch ( err ) {
374
- if ( err . message !== 'INVALID_DEFAULT_EXPORT' ) throw err
375
- invalidPages . add ( page )
376
- staticCheckSema . release ( )
363
+ if ( result . isStatic ) {
364
+ staticPages . add ( page )
365
+ isStatic = true
377
366
}
367
+ } catch ( err ) {
368
+ if ( err . message !== 'INVALID_DEFAULT_EXPORT' ) throw err
369
+ invalidPages . add ( page )
370
+ staticCheckSema . release ( )
378
371
}
379
372
}
380
373
@@ -411,7 +404,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
411
404
412
405
await writeBuildId ( distDir , buildId , selectivePageBuilding )
413
406
414
- if ( autoExport && staticPages . size > 0 ) {
407
+ if ( staticPages . size > 0 ) {
415
408
const exportApp = require ( '../export' ) . default
416
409
const exportOptions = {
417
410
silent : true ,
@@ -471,7 +464,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
471
464
} )
472
465
473
466
if ( flyingShuttle ) {
474
- if ( autoExport ) await flyingShuttle . mergePagesManifest ( )
467
+ await flyingShuttle . mergePagesManifest ( )
475
468
await flyingShuttle . save ( allStaticPages , pageInfos )
476
469
}
477
470
0 commit comments