@@ -100,7 +100,9 @@ class Stats {
100100 const optionOrLocalFallback = ( v , def ) =>
101101 typeof v !== "undefined"
102102 ? v
103- : typeof options . all !== "undefined" ? options . all : def ;
103+ : typeof options . all !== "undefined"
104+ ? options . all
105+ : def ;
104106
105107 const testAgainstGivenOption = item => {
106108 if ( typeof item === "string" ) {
@@ -135,6 +137,10 @@ class Stats {
135137 const showBuiltAt = optionOrLocalFallback ( options . builtAt , true ) ;
136138 const showAssets = optionOrLocalFallback ( options . assets , true ) ;
137139 const showEntrypoints = optionOrLocalFallback ( options . entrypoints , true ) ;
140+ const showChunkGroups = optionOrLocalFallback (
141+ options . chunkGroups ,
142+ ! forToString
143+ ) ;
138144 const showChunks = optionOrLocalFallback ( options . chunks , ! forToString ) ;
139145 const showChunkModules = optionOrLocalFallback ( options . chunkModules , true ) ;
140146 const showChunkOrigins = optionOrLocalFallback (
@@ -262,7 +268,9 @@ class Stats {
262268 text += `chunk ${ e . chunk . name || e . chunk . id } ${
263269 e . chunk . hasRuntime ( )
264270 ? " [entry]"
265- : e . chunk . canBeInitial ( ) ? " [initial]" : ""
271+ : e . chunk . canBeInitial ( )
272+ ? " [initial]"
273+ : ""
266274 } \n`;
267275 }
268276 if ( e . file ) {
@@ -396,15 +404,15 @@ class Stats {
396404 obj . assets . sort ( sortByField ( sortAssets ) ) ;
397405 }
398406
399- if ( showEntrypoints ) {
400- obj . entrypoints = { } ;
401- for ( const keyValuePair of compilation . entrypoints ) {
407+ const fnChunkGroup = groupMap => {
408+ const obj = { } ;
409+ for ( const keyValuePair of groupMap ) {
402410 const name = keyValuePair [ 0 ] ;
403- const ep = keyValuePair [ 1 ] ;
404- const children = ep . getChildrenByOrders ( ) ;
405- obj . entrypoints [ name ] = {
406- chunks : ep . chunks . map ( c => c . id ) ,
407- assets : ep . chunks . reduce (
411+ const cg = keyValuePair [ 1 ] ;
412+ const children = cg . getChildrenByOrders ( ) ;
413+ obj [ name ] = {
414+ chunks : cg . chunks . map ( c => c . id ) ,
415+ assets : cg . chunks . reduce (
408416 ( array , c ) => array . concat ( c . files || [ ] ) ,
409417 [ ]
410418 ) ,
@@ -436,9 +444,19 @@ class Stats {
436444 } , Object . create ( null ) )
437445 } ;
438446 if ( showPerformance ) {
439- obj . entrypoints [ name ] . isOverSizeLimit = ep . isOverSizeLimit ;
447+ obj [ name ] . isOverSizeLimit = cg . isOverSizeLimit ;
440448 }
441449 }
450+
451+ return obj ;
452+ } ;
453+
454+ if ( showEntrypoints ) {
455+ obj . entrypoints = fnChunkGroup ( compilation . entrypoints ) ;
456+ }
457+
458+ if ( showChunkGroups ) {
459+ obj . namedChunkGroups = fnChunkGroup ( compilation . namedChunkGroups ) ;
442460 }
443461
444462 const fnModule = module => {
@@ -866,22 +884,23 @@ class Stats {
866884 colors . normal ( obj . filteredAssets !== 1 ? " assets" : " asset" ) ;
867885 newline ( ) ;
868886 }
869- if ( obj . entrypoints ) {
870- for ( const name of Object . keys ( obj . entrypoints ) ) {
871- const ep = obj . entrypoints [ name ] ;
872- colors . normal ( "Entrypoint " ) ;
887+
888+ const processChunkGroups = ( namedGroups , prefix ) => {
889+ for ( const name of Object . keys ( namedGroups ) ) {
890+ const cg = namedGroups [ name ] ;
891+ colors . normal ( `${ prefix } ` ) ;
873892 colors . bold ( name ) ;
874- if ( ep . isOverSizeLimit ) {
893+ if ( cg . isOverSizeLimit ) {
875894 colors . normal ( " " ) ;
876895 colors . yellow ( "[big]" ) ;
877896 }
878897 colors . normal ( " =" ) ;
879- for ( const asset of ep . assets ) {
898+ for ( const asset of cg . assets ) {
880899 colors . normal ( " " ) ;
881900 colors . green ( asset ) ;
882901 }
883- for ( const name of Object . keys ( ep . childAssets ) ) {
884- const assets = ep . childAssets [ name ] ;
902+ for ( const name of Object . keys ( cg . childAssets ) ) {
903+ const assets = cg . childAssets [ name ] ;
885904 if ( assets && assets . length > 0 ) {
886905 colors . normal ( " " ) ;
887906 colors . magenta ( `(${ name } :` ) ;
@@ -894,7 +913,25 @@ class Stats {
894913 }
895914 newline ( ) ;
896915 }
916+ } ;
917+
918+ if ( obj . entrypoints ) {
919+ processChunkGroups ( obj . entrypoints , "Entrypoint" ) ;
897920 }
921+
922+ if ( obj . namedChunkGroups ) {
923+ let outputChunkGroups = obj . namedChunkGroups ;
924+ if ( obj . entrypoints ) {
925+ outputChunkGroups = Object . keys ( outputChunkGroups )
926+ . filter ( name => ! obj . entrypoints [ name ] )
927+ . reduce ( ( result , name ) => {
928+ result [ name ] = obj . namedChunkGroups [ name ] ;
929+ return result ;
930+ } , { } ) ;
931+ }
932+ processChunkGroups ( outputChunkGroups , "Chunk Group" ) ;
933+ }
934+
898935 const modulesByIdentifier = { } ;
899936 if ( obj . modules ) {
900937 for ( const module of obj . modules ) {
@@ -1260,6 +1297,7 @@ class Stats {
12601297 case "verbose" :
12611298 return {
12621299 entrypoints : true ,
1300+ chunkGroups : true ,
12631301 modules : false ,
12641302 chunks : true ,
12651303 chunkModules : true ,
@@ -1278,6 +1316,7 @@ class Stats {
12781316 case "detailed" :
12791317 return {
12801318 entrypoints : true ,
1319+ chunkGroups : true ,
12811320 chunks : true ,
12821321 chunkModules : false ,
12831322 chunkOrigins : true ,
0 commit comments