@@ -45,17 +45,18 @@ export class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency,
4545 // After initialization, if there are libraries with the same name+version later, they will not be searched recursively again
4646 // This will prevents infinite loops when circular dependencies are encountered.
4747 this . productionGraph [ dependencyId ] = { dependencies : [ ] }
48- const productionDeps = Object . entries ( resolvedDeps || { } )
49- . filter ( ( [ packageName ] ) => this . isProdDependency ( packageName , tree ) )
50- . map ( async ( [ , dependency ] ) => {
51- const childDependencyId = this . packageVersionString ( dependency )
52- await this . extractProductionDependencyGraph ( dependency , childDependencyId )
53- return childDependencyId
54- } )
5548
5649 const collectedDependencies : string [ ] = [ ]
57- for ( const dep of productionDeps ) {
58- collectedDependencies . push ( await dep )
50+ if ( resolvedDeps && Object . keys ( resolvedDeps ) . length > 0 ) {
51+ for ( const packageName in resolvedDeps ) {
52+ if ( ! this . isProdDependency ( packageName , tree ) ) {
53+ continue
54+ }
55+ const dependency = resolvedDeps [ packageName ]
56+ const childDependencyId = this . packageVersionString ( dependency )
57+ await this . extractProductionDependencyGraph ( dependency , childDependencyId )
58+ collectedDependencies . push ( childDependencyId )
59+ }
5960 }
6061 this . productionGraph [ dependencyId ] = { dependencies : collectedDependencies }
6162 }
0 commit comments