@@ -18,24 +18,26 @@ fn tsconfig() {
1818
1919 #[ rustfmt:: skip]
2020 let pass = [
21- ( f. clone ( ) , "ts-path" , f. join ( "foo.js" ) ) ,
22- ( f. join ( "nested" ) , "ts-path" , f. join ( "nested/test.js" ) ) ,
23- ( f. join ( "tsconfig/index" ) , "foo" , f. join ( "node_modules/tsconfig-index/foo.js" ) ) ,
21+ ( f. clone ( ) , None , "ts-path" , f. join ( "foo.js" ) ) ,
22+ ( f. join ( "nested" ) , None , "ts-path" , f. join ( "nested/test.js" ) ) ,
23+ ( f. join ( "tsconfig/index" ) , None , "foo" , f. join ( "node_modules/tsconfig-index/foo.js" ) ) ,
2424 // This requires reading package.json.tsconfig field
2525 // (f.join("tsconfig/field"), "foo", f.join("node_modules/tsconfig-field/foo.js"))
26- ( f. join ( "tsconfig/exports" ) , "foo" , f. join ( "node_modules/tsconfig-exports/foo.js" ) ) ,
27- ( f. join ( "tsconfig/extends-extension" ) , "foo" , f. join ( "tsconfig/extends-extension/foo.js" ) ) ,
28- ( f. join ( "tsconfig/extends-extensionless" ) , "foo" , f. join ( "node_modules/tsconfig-field/foo.js" ) )
26+ ( f. join ( "tsconfig/exports" ) , None , "foo" , f. join ( "node_modules/tsconfig-exports/foo.js" ) ) ,
27+ ( f. join ( "tsconfig/extends-extension" ) , None , "foo" , f. join ( "tsconfig/extends-extension/foo.js" ) ) ,
28+ ( f. join ( "tsconfig/extends-extensionless" ) , None , "foo" , f. join ( "node_modules/tsconfig-field/foo.js" ) ) ,
29+ ( f. join ( "tsconfig/extends-paths" ) , Some ( "src" ) , "@/index" , f. join ( "tsconfig/extends-paths/src/index.js" ) ) ,
2930 ] ;
3031
31- for ( path , request, expected) in pass {
32+ for ( dir , subdir , request, expected) in pass {
3233 let resolver = Resolver :: new ( ResolveOptions {
3334 tsconfig : Some ( TsconfigOptions {
34- config_file : path . join ( "tsconfig.json" ) ,
35+ config_file : dir . join ( "tsconfig.json" ) ,
3536 references : TsconfigReferences :: Auto ,
3637 } ) ,
3738 ..ResolveOptions :: default ( )
3839 } ) ;
40+ let path = subdir. map_or ( dir. clone ( ) , |subdir| dir. join ( subdir) ) ;
3941 let resolved_path = resolver. resolve ( & path, request) . map ( |f| f. full_path ( ) ) ;
4042 assert_eq ! ( resolved_path, Ok ( expected) , "{request} {path:?}" ) ;
4143 }
0 commit comments