@@ -355,7 +355,7 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
355355 return Ok ( path) ;
356356 }
357357 }
358- if let Some ( path) = self . load_roots ( specifier, ctx) {
358+ if let Some ( path) = self . load_roots ( cached_path , specifier, ctx) {
359359 return Ok ( path) ;
360360 }
361361 // 2. If X begins with '/'
@@ -1086,15 +1086,28 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
10861086 /// defaults to context configuration option.
10871087 ///
10881088 /// On non-Windows systems these requests are resolved as an absolute path first.
1089- fn load_roots ( & self , specifier : & str , ctx : & mut Ctx ) -> Option < CachedPath > {
1089+ fn load_roots (
1090+ & self ,
1091+ cached_path : & CachedPath ,
1092+ specifier : & str ,
1093+ ctx : & mut Ctx ,
1094+ ) -> Option < CachedPath > {
10901095 if self . options . roots . is_empty ( ) {
10911096 return None ;
10921097 }
10931098 if let Some ( specifier) = specifier. strip_prefix ( SLASH_START ) {
1094- for root in & self . options . roots {
1095- let cached_path = self . cache . value ( root) ;
1096- if let Ok ( path) = self . require_relative ( & cached_path, specifier, ctx) {
1097- return Some ( path) ;
1099+ if specifier. is_empty ( ) {
1100+ if self . options . roots . iter ( ) . any ( |root| root. as_path ( ) == cached_path. path ( ) ) {
1101+ if let Ok ( path) = self . require_relative ( cached_path, "./" , ctx) {
1102+ return Some ( path) ;
1103+ }
1104+ }
1105+ } else {
1106+ for root in & self . options . roots {
1107+ let cached_path = self . cache . value ( root) ;
1108+ if let Ok ( path) = self . require_relative ( & cached_path, specifier, ctx) {
1109+ return Some ( path) ;
1110+ }
10981111 }
10991112 }
11001113 }
0 commit comments