summaryrefslogtreecommitdiff
path: root/cli/npm/resolvers/common.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-21 12:03:48 -0500
committerGitHub <noreply@github.com>2023-02-21 12:03:48 -0500
commit3479bc76613761cf31f7557d482e691274c365f1 (patch)
treecd608c4206d61cde4141ea3ecfe5f4ef285b1d80 /cli/npm/resolvers/common.rs
parent608c855f1166e0ed76762fd9afd00bb52cc65032 (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/npm/resolvers/common.rs')
-rw-r--r--cli/npm/resolvers/common.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/cli/npm/resolvers/common.rs b/cli/npm/resolvers/common.rs
index 69950bee9..2b02e7721 100644
--- a/cli/npm/resolvers/common.rs
+++ b/cli/npm/resolvers/common.rs
@@ -18,7 +18,7 @@ use crate::args::Lockfile;
use crate::npm::cache::should_sync_download;
use crate::npm::resolution::NpmResolutionSnapshot;
use crate::npm::NpmCache;
-use crate::npm::NpmPackageNodeId;
+use crate::npm::NpmPackageId;
use crate::npm::NpmResolutionPackage;
pub trait InnerNpmPackageResolver: Send + Sync {
@@ -39,10 +39,7 @@ pub trait InnerNpmPackageResolver: Send + Sync {
specifier: &ModuleSpecifier,
) -> Result<PathBuf, AnyError>;
- fn package_size(
- &self,
- package_id: &NpmPackageNodeId,
- ) -> Result<u64, AnyError>;
+ fn package_size(&self, package_id: &NpmPackageId) -> Result<u64, AnyError>;
fn has_packages(&self) -> bool;
@@ -79,7 +76,7 @@ pub async fn cache_packages(
if sync_download {
// we're running the tests not with --quiet
// and we want the output to be deterministic
- packages.sort_by(|a, b| a.id.cmp(&b.id));
+ packages.sort_by(|a, b| a.pkg_id.cmp(&b.pkg_id));
}
let mut handles = Vec::with_capacity(packages.len());
@@ -90,7 +87,7 @@ pub async fn cache_packages(
let handle = tokio::task::spawn(async move {
cache
.ensure_package(
- (package.id.name.as_str(), &package.id.version),
+ (package.pkg_id.nv.name.as_str(), &package.pkg_id.nv.version),
&package.dist,
&registry_url,
)