@@ -81,13 +81,15 @@ export function generateEsbuildBuildStatsTable(
81
81
showTotalSize : boolean ,
82
82
showEstimatedTransferSize : boolean ,
83
83
budgetFailures ?: BudgetCalculatorResult [ ] ,
84
+ verbose ?: boolean ,
84
85
) : string {
85
86
const bundleInfo = generateBuildStatsData (
86
87
browserStats ,
87
88
colors ,
88
89
showTotalSize ,
89
90
showEstimatedTransferSize ,
90
91
budgetFailures ,
92
+ verbose ,
91
93
) ;
92
94
93
95
if ( serverStats . length ) {
@@ -100,7 +102,7 @@ export function generateEsbuildBuildStatsTable(
100
102
101
103
bundleInfo . push (
102
104
[ m ( 'Server bundles' ) ] ,
103
- ...generateBuildStatsData ( serverStats , colors , false , false , undefined ) ,
105
+ ...generateBuildStatsData ( serverStats , colors , false , false , undefined , verbose ) ,
104
106
) ;
105
107
}
106
108
@@ -120,6 +122,7 @@ export function generateBuildStatsTable(
120
122
showTotalSize ,
121
123
showEstimatedTransferSize ,
122
124
budgetFailures ,
125
+ true ,
123
126
) ;
124
127
125
128
return generateTableText ( bundleInfo , colors ) ;
@@ -131,6 +134,7 @@ function generateBuildStatsData(
131
134
showTotalSize : boolean ,
132
135
showEstimatedTransferSize : boolean ,
133
136
budgetFailures ?: BudgetCalculatorResult [ ] ,
137
+ verbose ?: boolean ,
134
138
) : ( string | number ) [ ] [ ] {
135
139
if ( data . length === 0 ) {
136
140
return [ ] ;
@@ -159,7 +163,9 @@ function generateBuildStatsData(
159
163
const changedLazyChunksStats : BundleStatsData [ ] = [ ] ;
160
164
161
165
let initialTotalRawSize = 0 ;
166
+ let changedLazyChunksCount = 0 ;
162
167
let initialTotalEstimatedTransferSize ;
168
+ const maxLazyChunksWithoutBudgetFailures = 15 ;
163
169
164
170
const budgets = new Map < string , string > ( ) ;
165
171
if ( budgetFailures ) {
@@ -187,9 +193,20 @@ function generateBuildStatsData(
187
193
188
194
for ( const { initial, stats } of data ) {
189
195
const [ files , names , rawSize , estimatedTransferSize ] = stats ;
196
+ if (
197
+ ! initial &&
198
+ ! verbose &&
199
+ changedLazyChunksStats . length >= maxLazyChunksWithoutBudgetFailures &&
200
+ ! budgets . has ( names ) &&
201
+ ! budgets . has ( files )
202
+ ) {
203
+ // Limit the number of lazy chunks displayed in the stats table when there is no budget failure and not in verbose mode.
204
+ changedLazyChunksCount ++ ;
205
+ continue ;
206
+ }
207
+
190
208
const getRawSizeColor = getSizeColor ( names , files ) ;
191
209
let data : BundleStatsData ;
192
-
193
210
if ( showEstimatedTransferSize ) {
194
211
data = [
195
212
g ( files ) ,
@@ -223,25 +240,22 @@ function generateBuildStatsData(
223
240
}
224
241
} else {
225
242
changedLazyChunksStats . push ( data ) ;
243
+ changedLazyChunksCount ++ ;
226
244
}
227
245
}
228
246
229
247
const bundleInfo : ( string | number ) [ ] [ ] = [ ] ;
230
248
const baseTitles = [ 'Names' , 'Raw size' ] ;
231
- const tableAlign : ( 'l' | 'r' ) [ ] = [ 'l' , 'l' , 'r' ] ;
232
249
233
250
if ( showEstimatedTransferSize ) {
234
251
baseTitles . push ( 'Estimated transfer size' ) ;
235
- tableAlign . push ( 'r' ) ;
236
252
}
237
253
238
254
// Entry chunks
239
255
if ( changedEntryChunksStats . length ) {
240
256
bundleInfo . push ( [ 'Initial chunk files' , ...baseTitles ] . map ( bold ) , ...changedEntryChunksStats ) ;
241
257
242
258
if ( showTotalSize ) {
243
- bundleInfo . push ( [ ] ) ;
244
-
245
259
const initialSizeTotalColor = getSizeColor ( 'bundle initial' , undefined , ( x ) => x ) ;
246
260
const totalSizeElements = [
247
261
' ' ,
@@ -255,7 +269,7 @@ function generateBuildStatsData(
255
269
: '-' ,
256
270
) ;
257
271
}
258
- bundleInfo . push ( totalSizeElements . map ( bold ) ) ;
272
+ bundleInfo . push ( [ ] , totalSizeElements . map ( bold ) ) ;
259
273
}
260
274
}
261
275
@@ -267,12 +281,22 @@ function generateBuildStatsData(
267
281
// Lazy chunks
268
282
if ( changedLazyChunksStats . length ) {
269
283
bundleInfo . push ( [ 'Lazy chunk files' , ...baseTitles ] . map ( bold ) , ...changedLazyChunksStats ) ;
284
+
285
+ if ( changedLazyChunksCount > changedLazyChunksStats . length ) {
286
+ bundleInfo . push ( [
287
+ dim (
288
+ `...and ${ changedLazyChunksCount - changedLazyChunksStats . length } more lazy chunks files. ` +
289
+ 'Use "--verbose" to show all the files.' ,
290
+ ) ,
291
+ ] ) ;
292
+ }
270
293
}
271
294
272
295
return bundleInfo ;
273
296
}
274
297
275
298
function generateTableText ( bundleInfo : ( string | number ) [ ] [ ] , colors : boolean ) : string {
299
+ const skipText = ( value : string ) => value . includes ( '...and ' ) ;
276
300
const longest : number [ ] = [ ] ;
277
301
for ( const item of bundleInfo ) {
278
302
for ( let i = 0 ; i < item . length ; i ++ ) {
@@ -281,6 +305,10 @@ function generateTableText(bundleInfo: (string | number)[][], colors: boolean):
281
305
}
282
306
283
307
const currentItem = item [ i ] . toString ( ) ;
308
+ if ( skipText ( currentItem ) ) {
309
+ continue ;
310
+ }
311
+
284
312
const currentLongest = ( longest [ i ] ??= 0 ) ;
285
313
const currentItemLength = removeColor ( currentItem ) . length ;
286
314
if ( currentLongest < currentItemLength ) {
@@ -298,10 +326,14 @@ function generateTableText(bundleInfo: (string | number)[][], colors: boolean):
298
326
}
299
327
300
328
const currentItem = item [ i ] . toString ( ) ;
329
+ if ( skipText ( currentItem ) ) {
330
+ continue ;
331
+ }
332
+
301
333
const currentItemLength = removeColor ( currentItem ) . length ;
302
334
const stringPad = ' ' . repeat ( longest [ i ] - currentItemLength ) ;
303
- // Last item is right aligned, thus we add the padding at the start .
304
- item [ i ] = longest . length === i + 1 ? stringPad + currentItem : currentItem + stringPad ;
335
+ // Values in columns at index 2 and 3 (Raw and Estimated sizes) are always right aligned .
336
+ item [ i ] = i >= 2 ? stringPad + currentItem : currentItem + stringPad ;
305
337
}
306
338
307
339
outputTable . push ( item . join ( seperator ) ) ;
0 commit comments