diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-17 09:13:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 09:13:22 -0400 |
commit | f4b9d8586215fc07c28998e5d896fefa876139b7 (patch) | |
tree | 9ee42eb4bb62af04b1c3b049cd179dfa6fe908bb /cli/resolver.rs | |
parent | 078def0ff8501bb07f3f286515acd8c6a2181037 (diff) |
fix(workspace): support resolving bare specifiers to npm pkgs within a workspace (#24611)
This makes bare specifiers for npm packages work when inside a
workspace, which emulates the same behaviour as when there's a
node_modules directory. The bare specifier can be overwritten by
specifying an import map entry or package.json dependency entry.
* https://github.com/denoland/deno_config/pull/88
Closes #24605
Diffstat (limited to 'cli/resolver.rs')
-rw-r--r-- | cli/resolver.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/resolver.rs b/cli/resolver.rs index 6049ec273..7c47795c4 100644 --- a/cli/resolver.rs +++ b/cli/resolver.rs @@ -536,6 +536,22 @@ impl Resolver for CliGraphResolver { Ok(resolution) => match resolution { MappedResolution::Normal(specifier) | MappedResolution::ImportMap(specifier) => Ok(specifier), + MappedResolution::WorkspaceNpmPackage { + target_pkg_json: pkg_json, + sub_path, + .. + } => self + .node_resolver + .as_ref() + .unwrap() + .resolve_package_sub_path_from_deno_module( + pkg_json.dir_path(), + sub_path.as_deref(), + Some(referrer), + to_node_mode(mode), + ) + .map_err(ResolveError::Other) + .map(|res| res.into_url()), // todo(dsherret): for byonm it should do resolution solely based on // the referrer and not the package.json MappedResolution::PackageJson { |