diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-12-19 17:09:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-19 17:09:54 +0100 |
commit | 383d40a33bee842a7462fb157f5faca263598d87 (patch) | |
tree | f80323ac9220a3f339bf474a93485f3d2f7d7af0 /ext/node/lib.rs | |
parent | d1f6b519907d3778f02436cf1fcc4f94f563acf8 (diff) |
fix(npm): conditional exports with --node-modules-dir (#17111)
This commit fixes conditional exports in `require()` implementation
if `--node-modules-dir` flag is used.
Diffstat (limited to 'ext/node/lib.rs')
-rw-r--r-- | ext/node/lib.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs index b2443db0b..e8ff3c549 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -542,6 +542,7 @@ pub fn op_require_as_file_path(file_or_url: String) -> String { #[op] fn op_require_resolve_exports( state: &mut OpState, + uses_local_node_modules_dir: bool, modules_path: String, _request: String, name: String, @@ -550,7 +551,9 @@ fn op_require_resolve_exports( ) -> Result<Option<String>, AnyError> { let resolver = state.borrow::<Rc<dyn RequireNpmResolver>>().clone(); - let pkg_path = if resolver.in_npm_package(&PathBuf::from(&modules_path)) { + let pkg_path = if resolver.in_npm_package(&PathBuf::from(&modules_path)) + && !uses_local_node_modules_dir + { modules_path } else { path_resolve(vec![modules_path, name]) |