import { ModuleGraphNode } from '../../types/BundleData' ; import { DiffResults } from '../../types/DiffResults' ; import handleAddedModule from './handleAddedModule' ; import handleChangedModule from './handleChangedModule' ; import handleRemovedModule from './handleRemovedModule' ; import { EnhancedModuleGraph } from './EnhancedModuleGraph' ; export default function diffModuleNode ( baselineGraph , comparisonGraph , moduleName , results ) { const baselineModule = baselineGraph . getModule ( moduleName ) ; const comparisonModule = comparisonGraph . getModule ( moduleName ) ; const baselineChunkGroups = getNamedChunkGroups ( baselineModule ) ; const comparisonChunkGroups = getNamedChunkGroups ( comparisonModule ) ; const allChunkGroups = new Set ( [ ... baselineChunkGroups , ... comparisonChunkGroups ] ) ; for ( let chunkGroupName of allChunkGroups ) { let chunkGroupDiff = results [ chunkGroupName ] ; if ( ! baselineChunkGroups . has ( chunkGroupName ) ) { handleAddedModule ( moduleName , baselineGraph , comparisonGraph , comparisonModule , chunkGroupName , chunkGroupDiff ) ; } else if ( ! comparisonChunkGroups . has ( chunkGroupName ) ) { handleRemovedModule ( moduleName , baselineGraph , comparisonGraph , baselineModule , chunkGroupName , chunkGroupDiff ) ; } else { handleChangedModule ( moduleName , baselineModule , comparisonModule , chunkGroupDiff ) ; } } } function getNamedChunkGroups ( module ) { return new Set ( ( module && module . namedChunkGroups ) || [ ] ) ; }