summaryrefslogtreecommitdiff
path: root/ext/node/lib.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-11-07 09:56:06 -0500
committerGitHub <noreply@github.com>2023-11-07 09:56:06 -0500
commit9201198efd6fb116585d4c26111669f4c1006e5d (patch)
tree746b2283da7edb457cea5eced2bc6cd7b42b8067 /ext/node/lib.rs
parent50e4806a2db66be289aa123a0bfd8dd8688712ba (diff)
fix(node): inspect ancestor directories when resolving cjs re-exports during analysis (#21104)
If a CJS re-export can't be resolved, it will check the ancestor directories, which is more similar to what `require` does at runtime.
Diffstat (limited to 'ext/node/lib.rs')
-rw-r--r--ext/node/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs
index 7a43fc4d4..cb395ad9a 100644
--- a/ext/node/lib.rs
+++ b/ext/node/lib.rs
@@ -83,7 +83,16 @@ pub trait NpmResolver: std::fmt::Debug + MaybeSend + MaybeSync {
fn in_npm_package(&self, specifier: &ModuleSpecifier) -> bool;
- fn in_npm_package_at_path(&self, path: &Path) -> bool {
+ fn in_npm_package_at_dir_path(&self, path: &Path) -> bool {
+ let specifier =
+ match ModuleSpecifier::from_directory_path(path.to_path_buf().clean()) {
+ Ok(p) => p,
+ Err(_) => return false,
+ };
+ self.in_npm_package(&specifier)
+ }
+
+ fn in_npm_package_at_file_path(&self, path: &Path) -> bool {
let specifier =
match ModuleSpecifier::from_file_path(path.to_path_buf().clean()) {
Ok(p) => p,