Skip to content

Commit e8b1acd

Browse files
committed
fix(tsconfig): respect Yarn PnP when resolving extends paths (#656)
closes vitejs/rolldown-vite#381
1 parent 18a69d4 commit e8b1acd

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext"
4+
}
5+
}

fixtures/pnp/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "lib/tsconfig.base.json"
3+
}

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,10 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
15021502
.clone_with_options(ResolveOptions {
15031503
extensions: vec![".json".into()],
15041504
main_files: vec!["tsconfig.json".into()],
1505+
#[cfg(feature = "yarn_pnp")]
1506+
yarn_pnp: self.options.yarn_pnp,
1507+
#[cfg(feature = "yarn_pnp")]
1508+
cwd: self.options.cwd.clone(),
15051509
..ResolveOptions::default()
15061510
})
15071511
.load_package_self_or_node_modules(directory, specifier, &mut Ctx::default())

src/tests/pnp.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,17 @@ fn resolve_global_cache() {
209209
.join("source-map.js")),
210210
);
211211
}
212+
213+
#[test]
214+
fn test_resolve_tsconfig_extends_with_pnp() {
215+
let fixture = super::fixture_root().join("pnp");
216+
let resolver = Resolver::new(ResolveOptions {
217+
cwd: Some(fixture.clone()),
218+
yarn_pnp: true,
219+
..ResolveOptions::default()
220+
});
221+
222+
let resolution = resolver.resolve_tsconfig(&fixture).expect("resolved");
223+
let compiler_options = resolution.compiler_options();
224+
assert_eq!(compiler_options.target, Some("esnext".to_string()));
225+
}

0 commit comments

Comments
 (0)