@@ -82,6 +82,7 @@ import { buildAppStaticPaths } from './static-paths/app'
82
82
import { buildPagesStaticPaths } from './static-paths/pages'
83
83
import type { PrerenderedRoute } from './static-paths/types'
84
84
import type { CacheControl } from '../server/lib/cache-control'
85
+ import { formatExpire , formatRevalidate } from './output/format'
85
86
86
87
export type ROUTER_TYPE = 'pages' | 'app'
87
88
@@ -347,7 +348,6 @@ export interface PageInfo {
347
348
*/
348
349
isRoutePPREnabled : boolean
349
350
ssgPageRoutes : string [ ] | null
350
- // TODO: initialCacheControl should be set per prerendered route.
351
351
initialCacheControl : CacheControl | undefined
352
352
pageDuration : number | undefined
353
353
ssgPageDurations : number [ ] | undefined
@@ -447,7 +447,7 @@ export async function printTreeView(
447
447
// Collect all the symbols we use so we can print the icons out.
448
448
const usedSymbols = new Set ( )
449
449
450
- const messages : [ string , string , string ] [ ] = [ ]
450
+ const messages : [ string , string , string , string , string ] [ ] = [ ]
451
451
452
452
const stats = await computeFromManifest (
453
453
{ build : buildManifest , app : appBuildManifest } ,
@@ -468,12 +468,39 @@ export async function printTreeView(
468
468
return
469
469
}
470
470
471
+ let showRevalidate = false
472
+ let showExpire = false
473
+
474
+ for ( const page of filteredPages ) {
475
+ const cacheControl = pageInfos . get ( page ) ?. initialCacheControl
476
+
477
+ if ( cacheControl ?. revalidate ) {
478
+ showRevalidate = true
479
+ }
480
+
481
+ if ( cacheControl ?. expire ) {
482
+ showExpire = true
483
+ }
484
+
485
+ if ( showRevalidate && showExpire ) {
486
+ break
487
+ }
488
+ }
489
+
471
490
messages . push (
472
491
[
473
492
routerType === 'app' ? 'Route (app)' : 'Route (pages)' ,
474
493
'Size' ,
475
494
'First Load JS' ,
476
- ] . map ( ( entry ) => underline ( entry ) ) as [ string , string , string ]
495
+ showRevalidate ? 'Revalidate' : '' ,
496
+ showExpire ? 'Expire' : '' ,
497
+ ] . map ( ( entry ) => underline ( entry ) ) as [
498
+ string ,
499
+ string ,
500
+ string ,
501
+ string ,
502
+ string ,
503
+ ]
477
504
)
478
505
479
506
filteredPages . forEach ( ( item , i , arr ) => {
@@ -522,16 +549,8 @@ export async function printTreeView(
522
549
523
550
usedSymbols . add ( symbol )
524
551
525
- // TODO: Rework this to be usable for app router routes.
526
- // See https://vercel.slack.com/archives/C02CDC2ALJH/p1739552318644119?thread_ts=1739550179.439319&cid=C02CDC2ALJH
527
- if ( pageInfo ?. initialCacheControl ?. revalidate ) usedSymbols . add ( 'ISR' )
528
-
529
552
messages . push ( [
530
- `${ border } ${ symbol } ${
531
- pageInfo ?. initialCacheControl ?. revalidate
532
- ? `${ item } (ISR: ${ pageInfo ?. initialCacheControl . revalidate } Seconds)`
533
- : item
534
- } ${
553
+ `${ border } ${ symbol } ${ item } ${
535
554
totalDuration > MIN_DURATION
536
555
? ` (${ getPrettyDuration ( totalDuration ) } )`
537
556
: ''
@@ -550,6 +569,12 @@ export async function printTreeView(
550
569
? getPrettySize ( pageInfo . totalSize , { strong : true } )
551
570
: ''
552
571
: '' ,
572
+ showRevalidate && pageInfo ?. initialCacheControl
573
+ ? formatRevalidate ( pageInfo . initialCacheControl )
574
+ : '' ,
575
+ showExpire && pageInfo ?. initialCacheControl
576
+ ? formatExpire ( pageInfo . initialCacheControl )
577
+ : '' ,
553
578
] )
554
579
555
580
const uniqueCssFiles =
@@ -569,6 +594,8 @@ export async function printTreeView(
569
594
`${ contSymbol } ${ innerSymbol } ${ getCleanName ( file ) } ` ,
570
595
typeof size === 'number' ? getPrettySize ( size ) : '' ,
571
596
'' ,
597
+ '' ,
598
+ '' ,
572
599
] )
573
600
} )
574
601
}
@@ -623,6 +650,10 @@ export async function printTreeView(
623
650
routes . forEach (
624
651
( { route, duration, avgDuration } , index , { length } ) => {
625
652
const innerSymbol = index === length - 1 ? '└' : '├'
653
+
654
+ const initialCacheControl =
655
+ pageInfos . get ( route ) ?. initialCacheControl
656
+
626
657
messages . push ( [
627
658
`${ contSymbol } ${ innerSymbol } ${ route } ${
628
659
duration > MIN_DURATION
@@ -635,6 +666,12 @@ export async function printTreeView(
635
666
} `,
636
667
'' ,
637
668
'' ,
669
+ showRevalidate && initialCacheControl
670
+ ? formatRevalidate ( initialCacheControl )
671
+ : '' ,
672
+ showExpire && initialCacheControl
673
+ ? formatExpire ( initialCacheControl )
674
+ : '' ,
638
675
] )
639
676
}
640
677
)
@@ -653,6 +690,8 @@ export async function printTreeView(
653
690
? getPrettySize ( sharedFilesSize , { strong : true } )
654
691
: '' ,
655
692
'' ,
693
+ '' ,
694
+ '' ,
656
695
] )
657
696
const sharedCssFiles : string [ ] = [ ]
658
697
const sharedJsChunks = [
@@ -686,14 +725,22 @@ export async function printTreeView(
686
725
return
687
726
}
688
727
689
- messages . push ( [ ` ${ innerSymbol } ${ cleanName } ` , getPrettySize ( size ) , '' ] )
728
+ messages . push ( [
729
+ ` ${ innerSymbol } ${ cleanName } ` ,
730
+ getPrettySize ( size ) ,
731
+ '' ,
732
+ '' ,
733
+ '' ,
734
+ ] )
690
735
} )
691
736
692
737
if ( restChunkCount > 0 ) {
693
738
messages . push ( [
694
739
` └ other shared chunks (total)` ,
695
740
getPrettySize ( restChunkSize ) ,
696
741
'' ,
742
+ '' ,
743
+ '' ,
697
744
] )
698
745
}
699
746
}
@@ -705,7 +752,7 @@ export async function printTreeView(
705
752
list : lists . app ,
706
753
} )
707
754
708
- messages . push ( [ '' , '' , '' ] )
755
+ messages . push ( [ '' , '' , '' , '' , '' ] )
709
756
}
710
757
711
758
pageInfos . set ( '/404' , {
@@ -735,17 +782,19 @@ export async function printTreeView(
735
782
. map ( gzipSize ? fsStatGzip : fsStat )
736
783
)
737
784
738
- messages . push ( [ '' , '' , '' ] )
785
+ messages . push ( [ '' , '' , '' , '' , '' ] )
739
786
messages . push ( [
740
787
'ƒ Middleware' ,
741
788
getPrettySize ( sum ( middlewareSizes ) , { strong : true } ) ,
742
789
'' ,
790
+ '' ,
791
+ '' ,
743
792
] )
744
793
}
745
794
746
795
print (
747
796
textTable ( messages , {
748
- align : [ 'l' , 'l ' , 'r' ] ,
797
+ align : [ 'l' , 'r' , 'r' , 'r ', 'r' ] ,
749
798
stringLength : ( str ) => stripAnsi ( str ) . length ,
750
799
} )
751
800
)
@@ -766,13 +815,6 @@ export async function printTreeView(
766
815
'(SSG)' ,
767
816
`prerendered as static HTML (uses ${ cyan ( staticFunctionInfo ) } )` ,
768
817
] ,
769
- usedSymbols . has ( 'ISR' ) && [
770
- '' ,
771
- '(ISR)' ,
772
- `incremental static regeneration (uses revalidate in ${ cyan (
773
- staticFunctionInfo
774
- ) } )`,
775
- ] ,
776
818
usedSymbols . has ( '◐' ) && [
777
819
'◐' ,
778
820
'(Partial Prerender)' ,
0 commit comments