@@ -30,17 +30,18 @@ export default class ModuleGraph {
3030 }
3131
3232 getResolvedModule ( dependency : Dependency ) : Module | null {
33- if ( this . #resolvedModuleMap. get ( dependency ) !== undefined ) {
34- return this . #resolvedModuleMap. get ( dependency ) ! ;
33+ let resolvedModule = this . #resolvedModuleMap. get ( dependency ) ;
34+ if ( resolvedModule === undefined ) {
35+ const depBinding = bindingDependencyFactory . getBinding ( dependency ) ;
36+ if ( depBinding ) {
37+ const binding = this . #inner. getResolvedModule ( depBinding ) ;
38+ resolvedModule = binding ? Module . __from_binding ( binding ) : null ;
39+ this . #resolvedModuleMap. set ( dependency , resolvedModule ) ;
40+ } else {
41+ return null ;
42+ }
3543 }
36- const depBinding = bindingDependencyFactory . getBinding ( dependency ) ;
37- if ( depBinding ) {
38- const binding = this . #inner. getResolvedModule ( depBinding ) ;
39- const module = binding ? Module . __from_binding ( binding ) : null ;
40- this . #resolvedModuleMap. set ( dependency , module ) ;
41- return module ;
42- }
43- return null ;
44+ return resolvedModule ;
4445 }
4546
4647 getParentModule ( dependency : Dependency ) : Module | null {
@@ -73,27 +74,28 @@ export default class ModuleGraph {
7374 }
7475
7576 getOutgoingConnections ( module : Module ) : ModuleGraphConnection [ ] {
76- if ( this . #outgoingConnectionsMap. get ( module ) ) {
77- return this . #outgoingConnectionsMap. get ( module ) ! ;
77+ let connections = this . #outgoingConnectionsMap. get ( module ) ;
78+ if ( connections === undefined ) {
79+ connections = this . #inner
80+ . getOutgoingConnections ( Module . __to_binding ( module ) )
81+ . map ( binding => ModuleGraphConnection . __from_binding ( binding ) ) ;
82+ this . #outgoingConnectionsMap. set ( module , connections ) ;
7883 }
79- const connections = this . #inner
80- . getOutgoingConnections ( Module . __to_binding ( module ) )
81- . map ( binding => ModuleGraphConnection . __from_binding ( binding ) ) ;
82- this . #outgoingConnectionsMap. set ( module , connections ) ;
8384 return connections ;
8485 }
8586
8687 getParentBlockIndex ( dependency : Dependency ) : number {
87- if ( this . #parentBlockIndexMap. get ( dependency ) !== undefined ) {
88- return this . #parentBlockIndexMap. get ( dependency ) ! ;
89- }
90- const depBinding = bindingDependencyFactory . getBinding ( dependency ) ;
91- if ( depBinding ) {
92- const index = this . #inner. getParentBlockIndex ( depBinding ) ;
93- this . #parentBlockIndexMap. set ( dependency , index ) ;
94- return index ;
88+ let index = this . #parentBlockIndexMap. get ( dependency ) ;
89+ if ( index === undefined ) {
90+ const depBinding = bindingDependencyFactory . getBinding ( dependency ) ;
91+ if ( depBinding ) {
92+ index = this . #inner. getParentBlockIndex ( depBinding ) ;
93+ this . #parentBlockIndexMap. set ( dependency , index ) ;
94+ } else {
95+ return - 1 ;
96+ }
9597 }
96- return - 1 ;
98+ return index ;
9799 }
98100
99101 isAsync ( module : Module ) : boolean {
0 commit comments