import { Stats } from '../../types/Stats' ; import { ChunkGroupData } from '../../types/BundleData' ; import { DataOptions } from '../../types/DataOptions' ; export function deriveChunkGroupData ( stats , options ) { const assetFilter = ( options && options . assetFilter ) || defaultAssetFilter ; const chunkGroupData = { } ; for ( let chunkGroupName of Object . keys ( stats . namedChunkGroups ) ) { const chunkGroup = stats . namedChunkGroups [ chunkGroupName ] ; let chunkGroupSize = 0 ; let assets = [ ] ; let ignoredAssets = [ ] ; for ( let { name , size } of chunkGroup . assets ) { if ( ! assetFilter ( name ) ) { ignoredAssets . push ( name ) ; } else { assets . push ( name ) ; chunkGroupSize += size ; } } chunkGroupData [ chunkGroupName ] = { size : chunkGroupSize , assets , ignoredAssets } ; } return chunkGroupData ; } function defaultAssetFilter ( asset ) { return ! asset . endsWith ( '.map' ) ; }