import { Stats , ChunkId } from '../../types/Stats' ; export default class NamedChunkGroupLookupMap { private map : Map < ChunkId , string [ ] > ; constructor ( stats ) { this . map = new Map ( ) ; for ( let name of Object . keys ( stats . namedChunkGroups ) ) { const chunkGroup = stats . namedChunkGroups [ name ] ; for ( let chunkId of chunkGroup . chunks ) { if ( ! this . map . has ( chunkId ) ) { this . map . set ( chunkId , [ ] ) ; } this . map . get ( chunkId ) . push ( name ) ; } } } getNamedChunkGroups ( chunks ) { const namedChunkGroups = new Set < string > ( ) ; for ( let chunkId of chunks ) { if ( this . map . has ( chunkId ) ) { for ( let namedChunkGroup of this . map . get ( chunkId ) ) { namedChunkGroups . add ( namedChunkGroup ) ; } } } return [ ... namedChunkGroups ] ; } }