import { ModuleGraphNode } from '../../types/BundleData' ; import { ChunkGroupDiff } from '../../types/DiffResults' ; import filterToChunkGroup from './filterToChunkGroup' ; import { EnhancedModuleGraph } from './EnhancedModuleGraph' ; import { getRemovedWeight } from './getWeight' ; export default function handleRemovedModule ( moduleName , baselineGraph , comparisonGraph , baselineModule , chunkGroupName , chunkGroupDiff ) { const baselineParents = filterToChunkGroup ( baselineModule . parents , chunkGroupName , baselineGraph ) ; if ( ! baselineParents . length ) { chunkGroupDiff . removed . push ( { module : moduleName , parents : [ ] , weight : getRemovedWeight ( moduleName , baselineGraph , comparisonGraph , chunkGroupName ) , } ) ; } else { const stillExistingParents = baselineParents . filter ( p => comparisonGraph . hasModule ( p , chunkGroupName ) ) ; if ( stillExistingParents . length ) { chunkGroupDiff . removed . push ( { module : moduleName , parents : stillExistingParents , weight : getRemovedWeight ( moduleName , baselineGraph , comparisonGraph , chunkGroupName ) , } ) ; } } }