@@ -269,11 +269,19 @@ export async function collectBuildTraces({
269
269
} )
270
270
}
271
271
}
272
- const serverIgnores = [
272
+
273
+ const sharedIgnores = [
273
274
'**/*.d.ts' ,
274
275
'**/*.map' ,
275
276
'**/next/dist/compiled/next-server/**/*.dev.js' ,
276
277
'**/node_modules/react{,-dom,-dom-server-turbopack}/**/*.development.js' ,
278
+
279
+ ...additionalIgnores ,
280
+ ...( config . experimental . outputFileTracingIgnores || [ ] ) ,
281
+ ]
282
+
283
+ const serverIgnores = [
284
+ ...sharedIgnores ,
277
285
isStandalone ? null : '**/next/dist/compiled/jest-worker/**/*' ,
278
286
'**/next/dist/compiled/webpack/(bundle4|bundle5).js' ,
279
287
'**/node_modules/webpack5/**/*' ,
@@ -294,32 +302,32 @@ export async function collectBuildTraces({
294
302
? [ '**/next/dist/compiled/@ampproject/toolbox-optimizer/**/*' ]
295
303
: [ ] ) ,
296
304
297
- ...additionalIgnores ,
298
-
299
305
...( isStandalone ? [ ] : TRACE_IGNORES ) ,
300
-
301
- ...( config . experimental . outputFileTracingIgnores || [ ] ) ,
302
306
] . filter ( nonNullable )
303
307
304
308
const minimalServerIgnores = [
305
309
...serverIgnores ,
306
310
'**/next/dist/compiled/edge-runtime/**/*' ,
307
311
'**/next/dist/server/web/sandbox/**/*' ,
312
+ '**/next/dist/server/post-process.js' ,
313
+ ]
314
+
315
+ const routesIgnores = [
316
+ ...sharedIgnores ,
317
+ '**/next/dist/compiled/next-server/**/*' ,
318
+ '**/next/dist/server/optimize-amp.js' ,
319
+ '**/next/dist/server/post-process.js' ,
308
320
]
309
321
310
- const serverIgnoreFn = ( minimal : boolean ) => ( pathname : string ) => {
322
+ const makeIgnoreFn = ( ignores : string [ ] ) => ( pathname : string ) => {
311
323
if ( path . isAbsolute ( pathname ) && ! pathname . startsWith ( root ) ) {
312
324
return true
313
325
}
314
326
315
- return isMatch (
316
- pathname ,
317
- minimal ? minimalServerIgnores : serverIgnores ,
318
- {
319
- contains : true ,
320
- dot : true ,
321
- }
322
- )
327
+ return isMatch ( pathname , ignores , {
328
+ contains : true ,
329
+ dot : true ,
330
+ } )
323
331
}
324
332
const traceContext = path . join ( nextServerEntry , '..' , '..' )
325
333
const serverTracedFiles = new Set < string > ( )
@@ -372,9 +380,11 @@ export async function collectBuildTraces({
372
380
] as [ Set < string > , string [ ] ] [ ] ) {
373
381
for ( const file of files ) {
374
382
if (
375
- ! serverIgnoreFn ( set === minimalServerTracedFiles ) (
376
- path . join ( traceContext , file )
377
- )
383
+ ! makeIgnoreFn (
384
+ set === minimalServerTracedFiles
385
+ ? minimalServerIgnores
386
+ : serverIgnores
387
+ ) ( path . join ( traceContext , file ) )
378
388
) {
379
389
addToTracedFiles ( traceContext , file , set )
380
390
}
@@ -433,14 +443,13 @@ export async function collectBuildTraces({
433
443
} )
434
444
const reasons = result . reasons
435
445
const fileList = result . fileList
436
-
437
446
for ( const file of result . esmFileList ) {
438
447
fileList . add ( file )
439
448
}
440
449
441
450
const parentFilesMap = getFilesMapFromReasons ( fileList , reasons )
442
- const cachedIgnoreFiles = new Map < string , boolean > ( )
443
- const cachedIgnoreFilesMinimal = new Map < string , boolean > ( )
451
+ const cachedLookupIgnore = new Map < string , boolean > ( )
452
+ const cachedLookupIgnoreMinimal = new Map < string , boolean > ( )
444
453
445
454
for ( const [ entries , tracedFiles ] of [
446
455
[ serverEntries , serverTracedFiles ] ,
@@ -458,11 +467,15 @@ export async function collectBuildTraces({
458
467
if (
459
468
! shouldIgnore (
460
469
curFile ,
461
- serverIgnoreFn ( tracedFiles === minimalServerTracedFiles ) ,
470
+ makeIgnoreFn (
471
+ tracedFiles === minimalServerTracedFiles
472
+ ? minimalServerIgnores
473
+ : serverIgnores
474
+ ) ,
462
475
reasons ,
463
476
tracedFiles === minimalServerTracedFiles
464
- ? cachedIgnoreFilesMinimal
465
- : cachedIgnoreFiles
477
+ ? cachedLookupIgnoreMinimal
478
+ : cachedLookupIgnore
466
479
)
467
480
) {
468
481
tracedFiles . add (
@@ -475,6 +488,8 @@ export async function collectBuildTraces({
475
488
476
489
const { entryNameFilesMap } = buildTraceContext ?. chunksTrace || { }
477
490
491
+ const cachedLookupIgnoreRoutes = new Map < string , boolean > ( )
492
+
478
493
await Promise . all (
479
494
[
480
495
...( entryNameFilesMap
@@ -514,14 +529,20 @@ export async function collectBuildTraces({
514
529
path . relative ( outputFileTracingRoot , file )
515
530
)
516
531
for ( const curFile of curFiles || [ ] ) {
517
- curTracedFiles . add (
518
- path
519
- . relative (
520
- traceOutputDir ,
521
- path . join ( outputFileTracingRoot , curFile )
522
- )
532
+ if (
533
+ ! shouldIgnore (
534
+ curFile ,
535
+ makeIgnoreFn ( routesIgnores ) ,
536
+ reasons ,
537
+ cachedLookupIgnoreRoutes
538
+ )
539
+ ) {
540
+ const filePath = path . join ( outputFileTracingRoot , curFile )
541
+ const outputFile = path
542
+ . relative ( traceOutputDir , filePath )
523
543
. replace ( / \\ / g, '/' )
524
- )
544
+ curTracedFiles . add ( outputFile )
545
+ }
525
546
}
526
547
}
527
548
@@ -556,7 +577,7 @@ export async function collectBuildTraces({
556
577
557
578
for ( const item of await fs . readdir ( contextDir ) ) {
558
579
const itemPath = path . relative ( root , path . join ( contextDir , item ) )
559
- if ( ! serverIgnoreFn ( false ) ( itemPath ) ) {
580
+ if ( ! makeIgnoreFn ( serverIgnores ) ( itemPath ) ) {
560
581
addToTracedFiles ( root , itemPath , serverTracedFiles )
561
582
addToTracedFiles ( root , itemPath , minimalServerTracedFiles )
562
583
}
0 commit comments