@@ -82,7 +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 { formatCacheControl } from './output/format'
85
+ import { formatExpire , formatRevalidate } from './output/format'
86
86
87
87
export type ROUTER_TYPE = 'pages' | 'app'
88
88
@@ -447,9 +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 , string ] [ ] = [ ]
451
-
452
- let showCacheLife = false
450
+ const messages : [ string , string , string , string , string ] [ ] = [ ]
453
451
454
452
const stats = await computeFromManifest (
455
453
{ build : buildManifest , app : appBuildManifest } ,
@@ -470,17 +468,39 @@ export async function printTreeView(
470
468
return
471
469
}
472
470
473
- showCacheLife = filteredPages . some (
474
- ( page ) => pageInfos . get ( page ) ?. initialCacheControl ?. revalidate
475
- )
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
+ }
476
489
477
490
messages . push (
478
491
[
479
492
routerType === 'app' ? 'Route (app)' : 'Route (pages)' ,
480
493
'Size' ,
481
494
'First Load JS' ,
482
- showCacheLife ? 'Cache Life' : '' ,
483
- ] . map ( ( entry ) => underline ( entry ) ) as [ string , 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
+ ]
484
504
)
485
505
486
506
filteredPages . forEach ( ( item , i , arr ) => {
@@ -549,8 +569,11 @@ export async function printTreeView(
549
569
? getPrettySize ( pageInfo . totalSize , { strong : true } )
550
570
: ''
551
571
: '' ,
552
- showCacheLife && pageInfo ?. initialCacheControl
553
- ? formatCacheControl ( pageInfo . initialCacheControl )
572
+ showRevalidate && pageInfo ?. initialCacheControl
573
+ ? formatRevalidate ( pageInfo . initialCacheControl )
574
+ : '' ,
575
+ showExpire && pageInfo ?. initialCacheControl
576
+ ? formatExpire ( pageInfo . initialCacheControl )
554
577
: '' ,
555
578
] )
556
579
@@ -572,6 +595,7 @@ export async function printTreeView(
572
595
typeof size === 'number' ? getPrettySize ( size ) : '' ,
573
596
'' ,
574
597
'' ,
598
+ '' ,
575
599
] )
576
600
} )
577
601
}
@@ -642,8 +666,11 @@ export async function printTreeView(
642
666
} `,
643
667
'' ,
644
668
'' ,
645
- showCacheLife && initialCacheControl
646
- ? formatCacheControl ( initialCacheControl )
669
+ showRevalidate && initialCacheControl
670
+ ? formatRevalidate ( initialCacheControl )
671
+ : '' ,
672
+ showExpire && initialCacheControl
673
+ ? formatExpire ( initialCacheControl )
647
674
: '' ,
648
675
] )
649
676
}
@@ -664,6 +691,7 @@ export async function printTreeView(
664
691
: '' ,
665
692
'' ,
666
693
'' ,
694
+ '' ,
667
695
] )
668
696
const sharedCssFiles : string [ ] = [ ]
669
697
const sharedJsChunks = [
@@ -702,6 +730,7 @@ export async function printTreeView(
702
730
getPrettySize ( size ) ,
703
731
'' ,
704
732
'' ,
733
+ '' ,
705
734
] )
706
735
} )
707
736
@@ -711,6 +740,7 @@ export async function printTreeView(
711
740
getPrettySize ( restChunkSize ) ,
712
741
'' ,
713
742
'' ,
743
+ '' ,
714
744
] )
715
745
}
716
746
}
@@ -722,7 +752,7 @@ export async function printTreeView(
722
752
list : lists . app ,
723
753
} )
724
754
725
- messages . push ( [ '' , '' , '' , '' ] )
755
+ messages . push ( [ '' , '' , '' , '' , '' ] )
726
756
}
727
757
728
758
pageInfos . set ( '/404' , {
@@ -752,18 +782,19 @@ export async function printTreeView(
752
782
. map ( gzipSize ? fsStatGzip : fsStat )
753
783
)
754
784
755
- messages . push ( [ '' , '' , '' , '' ] )
785
+ messages . push ( [ '' , '' , '' , '' , '' ] )
756
786
messages . push ( [
757
787
'ƒ Middleware' ,
758
788
getPrettySize ( sum ( middlewareSizes ) , { strong : true } ) ,
759
789
'' ,
760
790
'' ,
791
+ '' ,
761
792
] )
762
793
}
763
794
764
795
print (
765
796
textTable ( messages , {
766
- align : [ 'l' , 'r' , 'r' , 'r' ] ,
797
+ align : [ 'l' , 'r' , 'r' , 'r' , 'r' ] ,
767
798
stringLength : ( str ) => stripAnsi ( str ) . length ,
768
799
} )
769
800
)
@@ -790,7 +821,6 @@ export async function printTreeView(
790
821
'prerendered as static HTML with dynamic server-streamed content' ,
791
822
] ,
792
823
usedSymbols . has ( 'ƒ' ) && [ 'ƒ' , '(Dynamic)' , `server-rendered on demand` ] ,
793
- showCacheLife && [ '' , '(Cache Life)' , 'revalidate / expire' ] ,
794
824
] . filter ( ( x ) => x ) as [ string , string , string ] [ ] ,
795
825
{
796
826
align : [ 'l' , 'l' , 'l' ] ,
0 commit comments