@@ -656,10 +656,13 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
656656 // 2. If X.js is a file, load X.js as JavaScript text. STOP
657657 // 3. If X.json is a file, parse X.json to a JavaScript Object. STOP
658658 // 4. If X.node is a file, load X.node as binary addon. STOP
659- if let Some ( path) =
660- self . load_extensions ( cached_path, & self . options . extensions , tsconfig, ctx) ?
661- {
662- return Ok ( Some ( path) ) ;
659+ if !ctx. fully_specified {
660+ for extension in & self . options . extensions {
661+ let cached_path = cached_path. add_extension ( extension, self . cache . as_ref ( ) ) ;
662+ if let Some ( path) = self . load_alias_or_file ( & cached_path, tsconfig, ctx) ? {
663+ return Ok ( Some ( path) ) ;
664+ }
665+ }
663666 }
664667 Ok ( None )
665668 }
@@ -740,25 +743,6 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
740743 Ok ( None )
741744 }
742745
743- fn load_extensions (
744- & self ,
745- path : & CachedPath ,
746- extensions : & [ String ] ,
747- tsconfig : Option < & TsConfig > ,
748- ctx : & mut Ctx ,
749- ) -> ResolveResult {
750- if ctx. fully_specified {
751- return Ok ( None ) ;
752- }
753- for extension in extensions {
754- let cached_path = path. add_extension ( extension, self . cache . as_ref ( ) ) ;
755- if let Some ( path) = self . load_alias_or_file ( & cached_path, tsconfig, ctx) ? {
756- return Ok ( Some ( path) ) ;
757- }
758- }
759- Ok ( None )
760- }
761-
762746 fn load_realpath ( & self , cached_path : & CachedPath ) -> Result < PathBuf , ResolveError > {
763747 if self . options . symlinks {
764748 self . cache . canonicalize ( cached_path)
@@ -801,21 +785,18 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
801785 tsconfig : Option < & TsConfig > ,
802786 ctx : & mut Ctx ,
803787 ) -> ResolveResult {
804- for main_file in & self . options . main_files {
805- let cached_path = cached_path. normalize_with ( main_file, self . cache . as_ref ( ) ) ;
806- if self . options . enforce_extension . is_disabled ( )
807- && let Some ( path) = self . load_browser_field_or_alias ( & cached_path, tsconfig, ctx) ?
808- && self . check_restrictions ( path. path ( ) )
809- {
810- return Ok ( Some ( path) ) ;
811- }
812- // 1. If X/index.js is a file, load X/index.js as JavaScript text. STOP
813- // 2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
814- // 3. If X/index.node is a file, load X/index.node as binary addon. STOP
815- if let Some ( path) =
816- self . load_extensions ( & cached_path, & self . options . extensions , tsconfig, ctx) ?
817- {
818- return Ok ( Some ( path) ) ;
788+ if !ctx. fully_specified {
789+ for main_file in & self . options . main_files {
790+ // 1. If X/index.js is a file, load X/index.js as JavaScript text. STOP
791+ // 2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
792+ // 3. If X/index.node is a file, load X/index.node as binary addon. STOP
793+ for extension in & self . options . extensions {
794+ let cached_path =
795+ cached_path. add_name_and_extension ( main_file, extension, & self . cache ) ;
796+ if let Some ( path) = self . load_alias_or_file ( & cached_path, tsconfig, ctx) ? {
797+ return Ok ( Some ( path) ) ;
798+ }
799+ }
819800 }
820801 }
821802 Ok ( None )
0 commit comments