import { ModuleGraphNode } from '../../types/BundleData' ; import { ChunkGroupDiff } from '../../types/DiffResults' ; import filterToChunkGroup from './filterToChunkGroup' ; import { EnhancedModuleGraph } from './EnhancedModuleGraph' ; import { getAddedWeight } from './getWeight' ; export default function handleAddedModule ( moduleName , baselineGraph , comparisonGraph , comparisonModule , chunkGroupName , chunkGroupDiff ) { const comparisonParents = filterToChunkGroup ( comparisonModule . parents , chunkGroupName , comparisonGraph ) ; if ( ! comparisonParents . length ) { chunkGroupDiff . added . push ( { module : moduleName , parents : [ ] , weight : getAddedWeight ( moduleName , baselineGraph , comparisonGraph , chunkGroupName ) , } ) ; } else { const previouslyExistingParents = comparisonParents . filter ( p => baselineGraph . hasModule ( p , chunkGroupName ) ) ; if ( previouslyExistingParents . length ) { chunkGroupDiff . added . push ( { module : moduleName , parents : previouslyExistingParents , weight : getAddedWeight ( moduleName , baselineGraph , comparisonGraph , chunkGroupName ) , } ) ; } } }