@@ -324,6 +324,9 @@ Stats.prototype.toJson = function toJson(options, forToString) {
324324 return obj ;
325325 } ) ;
326326 }
327+ if ( showPerformance ) {
328+ obj . performance = compilation . options . performance ;
329+ }
327330 return obj ;
328331} ;
329332
@@ -395,7 +398,7 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
395398 buf . push ( "\n" ) ;
396399 }
397400
398- function table ( array , formats , align , splitter ) {
401+ function table ( array , align , splitter ) {
399402 var row ;
400403 var rows = array . length ;
401404 var col ;
@@ -406,16 +409,16 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
406409 colSizes [ col ] = 3 ;
407410 for ( row = 0 ; row < rows ; row ++ ) {
408411 for ( col = 0 ; col < cols ; col ++ ) {
409- value = array [ row ] [ col ] + "" ;
412+ value = array [ row ] [ col ] . value + "" ;
410413 if ( value . length > colSizes [ col ] ) {
411414 colSizes [ col ] = value . length ;
412415 }
413416 }
414417 }
415418 for ( row = 0 ; row < rows ; row ++ ) {
416419 for ( col = 0 ; col < cols ; col ++ ) {
417- var format = row === 0 ? colors . bold : formats [ col ] ;
418- value = array [ row ] [ col ] + "" ;
420+ var format = row === 0 ? colors . bold : array [ row ] [ col ] . color ;
421+ value = array [ row ] [ col ] . value + "" ;
419422 var l = value . length ;
420423 if ( align [ col ] === "l" )
421424 format ( value ) ;
@@ -440,6 +443,19 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
440443 . toPrecision ( 3 ) + " " + abbreviations [ index ] ;
441444 }
442445
446+ function isHugeBundle ( assetSize ) {
447+ var sizeLimit = obj . performance . maxAssetSize ;
448+ sizeLimit = sizeLimit * 1024 ;
449+ return sizeLimit < assetSize ;
450+ }
451+
452+ function getAssetColor ( asset , defaultColor ) {
453+ if ( isHugeBundle ( asset . size ) ) {
454+ return colors . yellow ;
455+ }
456+ return defaultColor ;
457+ }
458+
443459 if ( obj . hash ) {
444460 colors . normal ( "Hash: " ) ;
445461 colors . bold ( obj . hash ) ;
@@ -466,15 +482,20 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
466482 [ "Asset" , "Size" , "Chunks" , "" , "Chunk Names" ]
467483 ] ;
468484 obj . assets . forEach ( function ( asset ) {
469- t . push ( [
470- asset . name ,
471- formatSize ( asset . size ) ,
472- asset . chunks . join ( ", " ) ,
473- asset . emitted ? "[emitted]" : "" ,
474- asset . chunkNames . join ( ", " )
485+ t . push ( [ {
486+ value : asset . name , color : getAssetColor ( asset , colors . green )
487+ } , {
488+ value : formatSize ( asset . size ) , color : getAssetColor ( asset , colors . normal )
489+ } , {
490+ value : asset . chunks . join ( ", " ) , color : colors . bold
491+ } , {
492+ value : asset . emitted ? "[emitted]" : "" , color : colors . green
493+ } , {
494+ value : asset . chunkNames . join ( ", " ) , color : colors . normal
495+ }
475496 ] ) ;
476497 } ) ;
477- table ( t , [ colors . green , colors . normal , colors . bold , colors . green , colors . normal ] , "rrrll" ) ;
498+ table ( t , "rrrll" ) ;
478499 }
479500 if ( obj . entrypoints ) {
480501 Object . keys ( obj . entrypoints ) . forEach ( function ( name ) {
0 commit comments