@@ -892,37 +892,30 @@ export async function loadModule(path : string, options_ : Options = throwNotDef
892
892
}
893
893
894
894
895
- moduleCache [ path ] = new Loading (
895
+ moduleCache [ path ] = new Loading ( ( async ( ) => {
896
896
897
- ( async ( ) => {
897
+ if ( loadModule ) {
898
898
899
- if ( loadModule ) {
900
-
901
- const module = await loadModule ( path , options ) ;
902
- if ( module !== undefined )
903
- return moduleCache [ path ] = module ;
904
- }
905
-
906
- const res = await getFile ( path ) ;
907
-
908
- const file = typeof res === 'object' ? res : { content : res , extname : pathHandlers . extname ( path ) } ;
909
-
910
- const moduleHandlers = { ...defaultModuleHandlers , ...additionalModuleHandlers } ;
899
+ const module = await loadModule ( path , options ) ;
900
+ if ( module !== undefined )
901
+ return moduleCache [ path ] = module ;
902
+ }
911
903
912
- if ( ! ( file . extname in moduleHandlers ) )
913
- throw new TypeError ( `Unable to handle ${ file . extname } files (${ path } ), see additionalModuleHandlers` ) ;
904
+ const res = await getFile ( path ) ;
914
905
915
- if ( typeof file . content !== 'string' )
916
- throw new TypeError ( `Invalid module content (${ path } ): ${ file . content } ` ) ;
906
+ const file = typeof res === 'object' ? res : { content : res , extname : pathHandlers . extname ( path ) } ;
917
907
908
+ const moduleHandlers = { ...defaultModuleHandlers , ...additionalModuleHandlers } ;
918
909
919
- const module = await moduleHandlers [ file . extname ] ( file . content , path , options ) ;
910
+ if ( ! ( file . extname in moduleHandlers ) )
911
+ throw new TypeError ( `Unable to handle ${ file . extname } files (${ path } ), see additionalModuleHandlers` ) ;
920
912
921
- return moduleCache [ path ] = module ;
913
+ if ( typeof file . content !== 'string' )
914
+ throw new TypeError ( `Invalid module content (${ path } ): ${ file . content } ` ) ;
922
915
923
- } ) ( )
916
+ return moduleCache [ path ] = await moduleHandlers [ file . extname ] ( file . content , path , options ) ;
924
917
925
- ) ;
918
+ } ) ( ) ) ;
926
919
927
920
return await moduleCache [ path ] . promise ;
928
921
}
0 commit comments