@@ -1172,75 +1172,77 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
11721172 ) -> BoxFuture < ' a , Result < Arc < TsConfig > , ResolveError > > {
11731173 let fut = async move {
11741174 self . cache
1175- . tsconfig ( root, path, |mut tsconfig| async move {
1176- let directory = self . cache . value ( tsconfig. directory ( ) ) ;
1177- tracing:: trace!( tsconfig = ?tsconfig, "load_tsconfig" ) ;
1178-
1179- // Extend tsconfig
1180- if let Some ( extends) = & tsconfig. extends {
1181- let extended_tsconfig_paths = match extends {
1182- ExtendsField :: Single ( s) => {
1183- vec ! [ self . get_extended_tsconfig_path( & directory, & tsconfig, s) . await ?]
1184- }
1185- ExtendsField :: Multiple ( specifiers) => {
1186- try_join_all (
1187- specifiers. iter ( ) . map ( |s| {
1175+ . tsconfig ( root, path, |mut tsconfig| async move {
1176+ let directory = self . cache . value ( tsconfig. directory ( ) ) ;
1177+ tracing:: trace!( tsconfig = ?tsconfig, "load_tsconfig" ) ;
1178+
1179+ // Extend tsconfig
1180+ if let Some ( extends) = & tsconfig. extends {
1181+ let extended_tsconfig_paths = match extends {
1182+ ExtendsField :: Single ( s) => {
1183+ vec ! [
11881184 self . get_extended_tsconfig_path( & directory, & tsconfig, s)
1189- } ) ,
1190- )
1191- . await ?
1185+ . await ?,
1186+ ]
1187+ }
1188+ ExtendsField :: Multiple ( specifiers) => {
1189+ try_join_all ( specifiers. iter ( ) . map ( |s| {
1190+ self . get_extended_tsconfig_path ( & directory, & tsconfig, s)
1191+ } ) )
1192+ . await ?
1193+ }
1194+ } ;
1195+ for extended_tsconfig_path in extended_tsconfig_paths {
1196+ let extended_tsconfig = self
1197+ . load_tsconfig (
1198+ /* root */ false ,
1199+ & extended_tsconfig_path,
1200+ & TsconfigReferences :: Disabled ,
1201+ )
1202+ . await ?;
1203+ tsconfig. extend_tsconfig ( & extended_tsconfig) ;
11921204 }
1193- } ;
1194- for extended_tsconfig_path in extended_tsconfig_paths {
1195- let extended_tsconfig = self
1196- . load_tsconfig (
1197- /* root */ false ,
1198- & extended_tsconfig_path,
1199- & TsconfigReferences :: Disabled ,
1200- )
1201- . await ?;
1202- tsconfig. extend_tsconfig ( & extended_tsconfig) ;
12031205 }
1204- }
12051206
1206- // Load project references
1207- match references {
1208- TsconfigReferences :: Disabled => {
1209- tsconfig. references . drain ( ..) ;
1210- }
1211- TsconfigReferences :: Auto => { }
1212- TsconfigReferences :: Paths ( paths) => {
1213- tsconfig. references = paths
1214- . iter ( )
1215- . map ( |path| ProjectReference { path : path. clone ( ) , tsconfig : None } )
1216- . collect ( ) ;
1207+ // Load project references
1208+ match references {
1209+ TsconfigReferences :: Disabled => {
1210+ tsconfig. references . drain ( ..) ;
1211+ }
1212+ TsconfigReferences :: Auto => { }
1213+ TsconfigReferences :: Paths ( paths) => {
1214+ tsconfig. references = paths
1215+ . iter ( )
1216+ . map ( |path| ProjectReference { path : path. clone ( ) , tsconfig : None } )
1217+ . collect ( ) ;
1218+ }
12171219 }
1218- }
1219- if ! tsconfig. references . is_empty ( ) {
1220- let directory = tsconfig. directory ( ) . to_path_buf ( ) ;
1221- for reference in & mut tsconfig . references {
1222- let reference_tsconfig_path = directory . normalize_with ( & reference . path ) ;
1223- let tsconfig = self
1224- . cache
1225- . tsconfig (
1226- /* root */ true ,
1227- & reference_tsconfig_path ,
1228- | reference_tsconfig| async {
1229- if reference_tsconfig . path == tsconfig . path {
1230- return Err ( ResolveError :: TsconfigSelfReference (
1231- reference_tsconfig . path . clone ( ) ,
1232- ) ) ;
1233- }
1234- Ok ( reference_tsconfig )
1235- } ,
1236- )
1237- . await ? ;
1238- reference . tsconfig . replace ( tsconfig ) ;
1220+ if !tsconfig . references . is_empty ( ) {
1221+ let directory = tsconfig. directory ( ) . to_path_buf ( ) ;
1222+ for reference in & mut tsconfig. references {
1223+ let reference_tsconfig_path = directory . normalize_with ( & reference . path ) ;
1224+ let tsconfig = self
1225+ . cache
1226+ . tsconfig (
1227+ /* root */ true ,
1228+ & reference_tsconfig_path ,
1229+ |reference_tsconfig| async {
1230+ if reference_tsconfig. path == tsconfig . path {
1231+ return Err ( ResolveError :: TsconfigSelfReference (
1232+ reference_tsconfig . path . clone ( ) ,
1233+ ) ) ;
1234+ }
1235+ Ok ( reference_tsconfig )
1236+ } ,
1237+ )
1238+ . await ? ;
1239+ reference . tsconfig . replace ( tsconfig ) ;
1240+ }
12391241 }
1240- }
12411242
1242- Ok ( tsconfig)
1243- } ) . await
1243+ Ok ( tsconfig)
1244+ } )
1245+ . await
12441246 } ;
12451247 Box :: pin ( fut)
12461248 }
@@ -1614,7 +1616,7 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
16141616 target : & ' a JSONValue ,
16151617 pattern_match : Option < & ' a str > ,
16161618 is_imports : bool ,
1617- conditions : & ' a [ String ] ,
1619+ conditions : & ' a [ String ] ,
16181620 ctx : & ' a mut Ctx ,
16191621 ) -> BoxFuture < ' a , ResolveResult > {
16201622 let fut = async move {
@@ -1643,7 +1645,7 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
16431645 } ;
16441646 Ok ( target)
16451647 }
1646-
1648+
16471649 match target {
16481650 // 1. If target is a String, then
16491651 JSONValue :: String ( target) => {
@@ -1660,13 +1662,17 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
16601662 }
16611663 // 2. If patternMatch is a String, then
16621664 // 1. Return PACKAGE_RESOLVE(target with every instance of "*" replaced by patternMatch, packageURL + "/").
1663- let target =
1664- normalize_string_target ( target_key, target, pattern_match, package_url) ?;
1665+ let target = normalize_string_target (
1666+ target_key,
1667+ target,
1668+ pattern_match,
1669+ package_url,
1670+ ) ?;
16651671 let package_url = self . cache . value ( package_url) ;
16661672 // // 3. Return PACKAGE_RESOLVE(target, packageURL + "/").
16671673 return self . package_resolve ( & package_url, & target, ctx) . await ;
16681674 }
1669-
1675+
16701676 // 2. If target split on "/" or "\" contains any "", ".", "..", or "node_modules" segments after the first "." segment, case insensitive and including percent encoded variants, throw an Invalid Package Target error.
16711677 // 3. Let resolvedTarget be the URL resolution of the concatenation of packageURL and target.
16721678 // 4. Assert: resolvedTarget is contained in packageURL.
@@ -1740,11 +1746,11 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
17401746 ctx,
17411747 )
17421748 . await ;
1743-
1749+
17441750 if resolved. is_err ( ) && i == targets. len ( ) {
17451751 return resolved;
17461752 }
1747-
1753+
17481754 // 2. If resolved is undefined, continue the loop.
17491755 if let Ok ( Some ( path) ) = resolved {
17501756 // 3. Return resolved.
0 commit comments