import { ModuleGraph } from '../../../types/BundleData' ; export function validateGraph ( graph ) { const errors = [ ] ; for ( const moduleName of Object . keys ( graph ) ) { if ( moduleName . match ( / \+ \d+ modules$/ ) ) { errors . push ( 'Concatenated module has not been decomposed: ' + moduleName ) ; } const module = graph [ moduleName ] ; if ( ! module . directParents . length && ! module . lazyParents . length && ! module . entryType && ! moduleName . startsWith ( 'webpack/runtime/' ) ) { errors . push ( 'Orphaned module: ' + moduleName ) ; } for ( const parentName of [ ... module . directParents , ... module . lazyParents ] ) { if ( ! graph [ parentName ] ) { errors . push ( `Parent module doesn't exist: ${ parentName } -> ${ moduleName }` ) ; } } } if ( errors . length ) { for ( const error of errors ) { console . error ( 'Error: ' + error ) ; } throw new Error ( 'Errors detected in module graph.' ) ; } }