From 3479bc76613761cf31f7557d482e691274c365f1 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 21 Feb 2023 12:03:48 -0500 Subject: 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. --- cli/npm/resolvers/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cli/npm/resolvers/mod.rs') diff --git a/cli/npm/resolvers/mod.rs b/cli/npm/resolvers/mod.rs index a2638a15b..3ac373a54 100644 --- a/cli/npm/resolvers/mod.rs +++ b/cli/npm/resolvers/mod.rs @@ -30,9 +30,9 @@ use crate::util::fs::canonicalize_path_maybe_not_exists; use self::common::InnerNpmPackageResolver; use self::local::LocalNpmPackageResolver; use super::NpmCache; -use super::NpmPackageNodeId; +use super::NpmPackageId; +use super::NpmRegistryApi; use super::NpmResolutionSnapshot; -use super::RealNpmRegistryApi; /// State provided to the process via an environment variable. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -46,7 +46,7 @@ pub struct NpmPackageResolver { no_npm: bool, inner: Arc, local_node_modules_path: Option, - api: RealNpmRegistryApi, + api: NpmRegistryApi, cache: NpmCache, maybe_lockfile: Option>>, } @@ -62,13 +62,13 @@ impl std::fmt::Debug for NpmPackageResolver { } impl NpmPackageResolver { - pub fn new(cache: NpmCache, api: RealNpmRegistryApi) -> Self { + pub fn new(cache: NpmCache, api: NpmRegistryApi) -> Self { Self::new_inner(cache, api, false, None, None, None) } pub async fn new_with_maybe_lockfile( cache: NpmCache, - api: RealNpmRegistryApi, + api: NpmRegistryApi, no_npm: bool, local_node_modules_path: Option, initial_snapshot: Option, @@ -105,7 +105,7 @@ impl NpmPackageResolver { fn new_inner( cache: NpmCache, - api: RealNpmRegistryApi, + api: NpmRegistryApi, no_npm: bool, local_node_modules_path: Option, maybe_snapshot: Option, @@ -187,7 +187,7 @@ impl NpmPackageResolver { /// Attempts to get the package size in bytes. pub fn package_size( &self, - package_id: &NpmPackageNodeId, + package_id: &NpmPackageId, ) -> Result { self.inner.package_size(package_id) } -- cgit v1.2.3