summaryrefslogtreecommitdiff
path: root/cli/npm/resolvers/mod.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/mod.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/mod.rs')
-rw-r--r--cli/npm/resolvers/mod.rs14
1 files changed, 7 insertions, 7 deletions
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<dyn InnerNpmPackageResolver>,
local_node_modules_path: Option<PathBuf>,
- api: RealNpmRegistryApi,
+ api: NpmRegistryApi,
cache: NpmCache,
maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
}
@@ -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<PathBuf>,
initial_snapshot: Option<NpmResolutionSnapshot>,
@@ -105,7 +105,7 @@ impl NpmPackageResolver {
fn new_inner(
cache: NpmCache,
- api: RealNpmRegistryApi,
+ api: NpmRegistryApi,
no_npm: bool,
local_node_modules_path: Option<PathBuf>,
maybe_snapshot: Option<NpmResolutionSnapshot>,
@@ -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<u64, AnyError> {
self.inner.package_size(package_id)
}