summaryrefslogtreecommitdiff
path: root/cli/lsp/resolver.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-17 09:13:22 -0400
committerGitHub <noreply@github.com>2024-07-17 09:13:22 -0400
commitf4b9d8586215fc07c28998e5d896fefa876139b7 (patch)
tree9ee42eb4bb62af04b1c3b049cd179dfa6fe908bb /cli/lsp/resolver.rs
parent078def0ff8501bb07f3f286515acd8c6a2181037 (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/lsp/resolver.rs')
-rw-r--r--cli/lsp/resolver.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs
index 21b46255c..2ca93114d 100644
--- a/cli/lsp/resolver.rs
+++ b/cli/lsp/resolver.rs
@@ -529,6 +529,13 @@ fn create_graph_resolver(
node_resolver: node_resolver.cloned(),
npm_resolver: npm_resolver.cloned(),
workspace_resolver: Arc::new(WorkspaceResolver::new_raw(
+ Arc::new(
+ config_data
+ .map(|d| d.workspace_root_dir.clone())
+ // this is fine because this value is only used to filter bare
+ // specifier resolution to workspace npm packages when in a workspace
+ .unwrap_or_else(|| ModuleSpecifier::parse("file:///").unwrap()),
+ ),
config_data.and_then(|d| d.import_map.as_ref().map(|i| (**i).clone())),
config_data
.and_then(|d| d.package_json.clone())