Skip to content

Commit feafed8

Browse files
committed
feat: port tsconfck (find tsconfig files) (#854)
Adds `Resolver::find_tsconfig`. ``` /// Finds the `tsconfig` to which this `path` belongs. /// /// Algorithm: /// /// 1. Search for `tsconfig.json` in ancestor directories. /// 2. If the path is not included in this `tsconfig.json` through the `files`, `include`, or `exclude` fields: /// 2.1. Search through project references until a referenced `tsconfig` includes this file. /// 2.2. If none of the references include this path, return the `tsconfig.json` found in step 1. /// /// # Errors /// /// * Returns an error if the tsconfig is invalid, including any extended or referenced tsconfigs. ``` - [x] tracing - [x] test windows - [x] add benchmark - [x] add cache
1 parent 3d70607 commit feafed8

File tree

150 files changed

+1133
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+1133
-70
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ target/
44
/napi/node_modules
55
/fixtures/pnpm/node_modules
66
/fixtures/yarn/node_modules
7+
/fixtures/tsconfck/node_modules
78
fuzz/Cargo.lock

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ name = "resolver"
7979

8080
[dependencies]
8181
cfg-if = "1"
82+
fast-glob = "1"
8283
indexmap = { version = "2", features = ["serde"] }
8384
json-strip-comments = "3.1"
8485
once_cell = "1" # Use `std::sync::OnceLock::get_or_try_init` when it is stable.

README.md

Lines changed: 10 additions & 7 deletions

benches/resolver.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ fn bench_resolver_memory(c: &mut Criterion) {
224224
});
225225
},
226226
);
227+
228+
group.bench_with_input(BenchmarkId::from_parameter("find tsconfig"), &data, |b, data| {
229+
let oxc_resolver = oxc_resolver_memory();
230+
let paths = data
231+
.iter()
232+
.map(|(path, request)| oxc_resolver.resolve(path, request).unwrap().into_path_buf())
233+
.collect::<Vec<_>>();
234+
b.iter(|| {
235+
for path in &paths {
236+
let _ = oxc_resolver.find_tsconfig(path);
237+
}
238+
});
239+
});
227240
}
228241

229242
fn bench_resolver_real(c: &mut Criterion) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!node_modules

fixtures/tsconfck/find/a/b/bar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const bar = 'bar';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

fixtures/tsconfck/find/a/b/c/x.ts

Whitespace-only changes.

fixtures/tsconfck/find/a/b/c/y.js

Whitespace-only changes.

0 commit comments

Comments
 (0)