@@ -150,20 +150,35 @@ const normalizeRsdoctorModuleGraph = (artifact: RsdoctorArtifact): ObservedModul
150150
151151 const edgeKeys = new Set < string > ( ) ;
152152 const edges : ObservedModuleGraph [ 'edges' ] = [ ] ;
153- for ( const row of Array . isArray ( moduleGraph . dependencies ) ? moduleGraph . dependencies : [ ] ) {
154- if ( ! isObject ( row ) ) continue ;
155- const usesDependencyShape = Object . hasOwn ( row , 'dependency' ) ;
156- const from = getId ( usesDependencyShape ? row . module : row . issuer ) ;
157- const to = getId ( usesDependencyShape ? row . dependency : row . module ) ;
158- if ( from === undefined || to === undefined ) continue ;
153+ const addEdge = ( from : string | undefined , to : string | undefined ) : void => {
154+ if ( from === undefined || to === undefined ) return ;
159155 if ( ! modulesById . has ( from ) || ! modulesById . has ( to ) ) {
160156 if ( ! issues . includes ( 'dangling-edge' ) ) issues . push ( 'dangling-edge' ) ;
161- continue ;
157+ return ;
162158 }
163159 const key = `${ from } \u0000${ to } ` ;
164- if ( edgeKeys . has ( key ) ) continue ;
160+ if ( edgeKeys . has ( key ) ) return ;
165161 edgeKeys . add ( key ) ;
166162 edges . push ( { from, to } ) ;
163+ } ;
164+ for ( const row of Array . isArray ( moduleGraph . dependencies ) ? moduleGraph . dependencies : [ ] ) {
165+ if ( ! isObject ( row ) ) continue ;
166+ const usesDependencyShape = Object . hasOwn ( row , 'dependency' ) ;
167+ addEdge (
168+ getId ( usesDependencyShape ? row . module : row . issuer ) ,
169+ getId ( usesDependencyShape ? row . dependency : row . module ) ,
170+ ) ;
171+ }
172+
173+ for ( const row of Array . isArray ( moduleGraph . modules ) ? moduleGraph . modules : [ ] ) {
174+ if ( ! isObject ( row ) ) continue ;
175+ const moduleId = getId ( row . id ) ;
176+ for ( const importerId of Array . isArray ( row . imported ) ? row . imported . map ( getId ) : [ ] ) {
177+ addEdge ( importerId , moduleId ) ;
178+ }
179+ for ( const childId of Array . isArray ( row . modules ) ? row . modules . map ( getId ) : [ ] ) {
180+ addEdge ( moduleId , childId ) ;
181+ }
167182 }
168183
169184 return {
0 commit comments