@@ -185,6 +185,7 @@ class Builder {
185
185
* @param destination
186
186
*/
187
187
async processAndCopyRoutesManifest ( source : string , destination : string ) {
188
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
188
189
const routesManifest = require ( source ) as RoutesManifest ;
189
190
190
191
// Remove default trailing slash redirects as they are already handled without regex matching.
@@ -261,6 +262,7 @@ class Builder {
261
262
async buildDefaultLambda (
262
263
buildManifest : OriginRequestDefaultHandlerManifest
263
264
) : Promise < void [ ] > {
265
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
264
266
const prerenderManifest = require ( join (
265
267
this . dotNextDir ,
266
268
"prerender-manifest.json"
@@ -321,14 +323,7 @@ class Builder {
321
323
}
322
324
}
323
325
) ,
324
- // copy chunks if present and not using serverless trace
325
- ! this . buildOptions . useServerlessTraceTarget &&
326
- fse . existsSync ( join ( this . serverlessDir , "chunks" ) )
327
- ? fse . copy (
328
- join ( this . serverlessDir , "chunks" ) ,
329
- join ( this . outputDir , DEFAULT_LAMBDA_CODE_DIR , "chunks" )
330
- )
331
- : Promise . resolve ( ) ,
326
+ this . copyChunks ( DEFAULT_LAMBDA_CODE_DIR ) ,
332
327
fse . copy (
333
328
join ( this . dotNextDir , "prerender-manifest.json" ) ,
334
329
join ( this . outputDir , DEFAULT_LAMBDA_CODE_DIR , "prerender-manifest.json" )
@@ -388,14 +383,7 @@ class Builder {
388
383
join ( this . serverlessDir , "pages/api" ) ,
389
384
join ( this . outputDir , API_LAMBDA_CODE_DIR , "pages/api" )
390
385
) ,
391
- // copy chunks if present and not using serverless trace
392
- ! this . buildOptions . useServerlessTraceTarget &&
393
- fse . existsSync ( join ( this . serverlessDir , "chunks" ) )
394
- ? fse . copy (
395
- join ( this . serverlessDir , "chunks" ) ,
396
- join ( this . outputDir , API_LAMBDA_CODE_DIR , "chunks" )
397
- )
398
- : Promise . resolve ( ) ,
386
+ this . copyChunks ( API_LAMBDA_CODE_DIR ) ,
399
387
fse . writeJson (
400
388
join ( this . outputDir , API_LAMBDA_CODE_DIR , "manifest.json" ) ,
401
389
apiBuildManifest
@@ -421,6 +409,7 @@ class Builder {
421
409
join ( this . outputDir , REGENERATION_LAMBDA_CODE_DIR ) ,
422
410
! ! this . buildOptions . minifyHandlers
423
411
) ,
412
+ this . copyChunks ( REGENERATION_LAMBDA_CODE_DIR ) ,
424
413
fse . copy (
425
414
join ( this . serverlessDir , "pages" ) ,
426
415
join ( this . outputDir , REGENERATION_LAMBDA_CODE_DIR , "pages" ) ,
@@ -441,6 +430,19 @@ class Builder {
441
430
] ) ;
442
431
}
443
432
433
+ /**
434
+ * copy chunks if present and not using serverless trace
435
+ */
436
+ async copyChunks ( buildDir : string ) : Promise < void > {
437
+ return ! this . buildOptions . useServerlessTraceTarget &&
438
+ fse . existsSync ( join ( this . serverlessDir , "chunks" ) )
439
+ ? fse . copy (
440
+ join ( this . serverlessDir , "chunks" ) ,
441
+ join ( this . outputDir , buildDir , "chunks" )
442
+ )
443
+ : Promise . resolve ( ) ;
444
+ }
445
+
444
446
/**
445
447
* Build image optimization lambda (supported by Next.js 10)
446
448
* @param buildManifest
@@ -793,11 +795,13 @@ class Builder {
793
795
await restoreUserConfig ( ) ;
794
796
}
795
797
798
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
796
799
const routesManifest = require ( join (
797
800
this . dotNextDir ,
798
801
"routes-manifest.json"
799
802
) ) ;
800
803
804
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
801
805
const prerenderManifest = require ( join (
802
806
this . dotNextDir ,
803
807
"prerender-manifest.json"
0 commit comments