Skip to content

Commit

Permalink
Fix resolving of builtins with tsconfig + baseUrl (#8893)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcompiles authored Mar 17, 2023
1 parent 41f38cf commit b2331a1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"baseUrl": "."
}
}
12 changes: 12 additions & 0 deletions packages/utils/node-resolver-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,18 @@ mod tests {
module: "ts-path".into()
},
);
assert_eq!(
test_resolver()
.resolve(
"zlib",
&root().join("tsconfig/builtins/thing.js"),
SpecifierType::Cjs
)
.result
.unwrap()
.0,
Resolution::Builtin("zlib".into())
);

let invalidations = test_resolver()
.resolve("ts-path", &root().join("foo.js"), SpecifierType::Esm)
Expand Down
5 changes: 5 additions & 0 deletions packages/utils/node-resolver-rs/src/tsconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ impl<'a> TsConfig<'a> {
}
}

if matches!(specifier, Specifier::Builtin(..)) {
// If specifier is a builtin then there's no match
return Either::Right(Either::Right(std::iter::empty()));
}

// If no paths were found, try relative to the base url.
Either::Right(base_url_iter)
}
Expand Down

0 comments on commit b2331a1

Please sign in to comment.