diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-02-21 12:03:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 12:03:48 -0500 |
commit | 3479bc76613761cf31f7557d482e691274c365f1 (patch) | |
tree | cd608c4206d61cde4141ea3ecfe5f4ef285b1d80 /cli/lsp/diagnostics.rs | |
parent | 608c855f1166e0ed76762fd9afd00bb52cc65032 (diff) |
fix(npm): improve peer dependency resolution (#17835)
This PR fixes peer dependency resolution to only resolve peers based on
the current graph traversal path. Previously, it would resolve a peers
by looking at a graph node's ancestors, which is not correct because
graph nodes are shared by different resolutions.
It also stores more information about peer dependency resolution in the
lockfile.
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r-- | cli/lsp/diagnostics.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index e33059001..f8f3aa371 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -26,7 +26,7 @@ use deno_core::serde::Deserialize; use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::ModuleSpecifier; -use deno_graph::npm::NpmPackageReference; +use deno_graph::npm::NpmPackageReqReference; use deno_graph::Resolution; use deno_graph::ResolutionError; use deno_graph::SpecifierError; @@ -614,7 +614,7 @@ pub enum DenoDiagnostic { /// A data module was not found in the cache. NoCacheData(ModuleSpecifier), /// A remote npm package reference was not found in the cache. - NoCacheNpm(NpmPackageReference, ModuleSpecifier), + NoCacheNpm(NpmPackageReqReference, ModuleSpecifier), /// A local module was not found on the local file system. NoLocal(ModuleSpecifier), /// The specifier resolved to a remote specifier that was redirected to @@ -905,7 +905,8 @@ fn diagnose_resolution( .push(DenoDiagnostic::NoAssertType.to_lsp_diagnostic(&range)), } } - } else if let Ok(pkg_ref) = NpmPackageReference::from_specifier(specifier) + } else if let Ok(pkg_ref) = + NpmPackageReqReference::from_specifier(specifier) { if let Some(npm_resolver) = &snapshot.maybe_npm_resolver { // show diagnostics for npm package references that aren't cached @@ -929,7 +930,7 @@ fn diagnose_resolution( } else if let Some(npm_resolver) = &snapshot.maybe_npm_resolver { // check that a @types/node package exists in the resolver let types_node_ref = - NpmPackageReference::from_str("npm:@types/node").unwrap(); + NpmPackageReqReference::from_str("npm:@types/node").unwrap(); if npm_resolver .resolve_package_folder_from_deno_module(&types_node_ref.req) .is_err() |