summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-06-30 08:49:49 -0400
committerGitHub <noreply@github.com>2023-06-30 08:49:49 -0400
commitdd508c9c8970fc6565cfd50cd3e01e8571425347 (patch)
tree2affaa4725235727e5fd6575aebce27b2b5f70fa
parentaec761f75574a71f11e3faec4764aca2803e48e2 (diff)
fix(npm): support siblings that are peer dependencies of each other (#19657)
https://github.com/denoland/deno_npm/pull/20
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml2
-rw-r--r--cli/Cargo.toml2
-rw-r--r--cli/npm/resolution.rs44
4 files changed, 37 insertions, 19 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c3fd56f96..f25aa141f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1329,9 +1329,9 @@ dependencies = [
[[package]]
name = "deno_npm"
-version = "0.8.1"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f396676bc09754d7afdbf8887e501bf5cd4ecbec6607a5540ee5c7338cae713d"
+checksum = "f4b0de941ffd64e68ec1adbaf24c045214be3232ca316f32f55b6b2197b4f5b3"
dependencies = [
"anyhow",
"async-trait",
@@ -1945,9 +1945,9 @@ dependencies = [
[[package]]
name = "eszip"
-version = "0.44.0"
+version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "176a97e524a9cfa38393fae75c97d249cf41742fc40664529206c5249c12b599"
+checksum = "bbf5a0f47c2e73cb7631accc282ebda9bc9ed9b2034abfddec983dc9c8f78e7a"
dependencies = [
"anyhow",
"base64 0.21.0",
diff --git a/Cargo.toml b/Cargo.toml
index 79fdafaef..585797a05 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,7 +53,7 @@ deno_bench_util = { version = "0.103.0", path = "./bench_util" }
test_util = { path = "./test_util" }
deno_lockfile = "0.14.1"
deno_media_type = { version = "0.1.0", features = ["module_specifier"] }
-deno_npm = "0.8.1"
+deno_npm = "0.9.0"
deno_semver = "0.2.2"
# exts
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 826a0cbea..69bc67bfd 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -51,7 +51,7 @@ deno_npm.workspace = true
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }
deno_semver.workspace = true
deno_task_shell = "=0.12.0"
-eszip = "=0.44.0"
+eszip = "=0.45.0"
napi_sym.workspace = true
async-trait.workspace = true
diff --git a/cli/npm/resolution.rs b/cli/npm/resolution.rs
index 1f4dda1e1..37c8aa08c 100644
--- a/cli/npm/resolution.rs
+++ b/cli/npm/resolution.rs
@@ -14,7 +14,8 @@ use deno_npm::resolution::NpmPackageVersionResolutionError;
use deno_npm::resolution::NpmPackagesPartitioned;
use deno_npm::resolution::NpmResolutionError;
use deno_npm::resolution::NpmResolutionSnapshot;
-use deno_npm::resolution::NpmResolutionSnapshotCreateOptions;
+use deno_npm::resolution::NpmResolutionSnapshotPendingResolver;
+use deno_npm::resolution::NpmResolutionSnapshotPendingResolverOptions;
use deno_npm::resolution::PackageNotFoundFromReferrerError;
use deno_npm::resolution::PackageNvNotFoundError;
use deno_npm::resolution::PackageReqNotFoundError;
@@ -59,15 +60,7 @@ impl NpmResolution {
maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
) -> Self {
let snapshot =
- NpmResolutionSnapshot::new(NpmResolutionSnapshotCreateOptions {
- api: api.clone(),
- snapshot: initial_snapshot.unwrap_or_default(),
- // WARNING: When bumping this version, check if anything needs to be
- // updated in the `setNodeOnlyGlobalNames` call in 99_main_compiler.js
- types_node_version_req: Some(
- VersionReq::parse_from_npm("18.0.0 - 18.11.18").unwrap(),
- ),
- });
+ NpmResolutionSnapshot::new(initial_snapshot.unwrap_or_default());
Self::new(api, snapshot, maybe_lockfile)
}
@@ -220,7 +213,12 @@ impl NpmResolution {
) -> Result<NpmPackageNv, NpmPackageVersionResolutionError> {
debug_assert_eq!(pkg_req.name, package_info.name);
let mut snapshot = self.snapshot.write();
- let nv = snapshot.resolve_package_req_as_pending(pkg_req, package_info)?;
+ let pending_resolver = get_npm_pending_resolver(&self.api);
+ let nv = pending_resolver.resolve_package_req_as_pending(
+ &mut snapshot,
+ pkg_req,
+ package_info,
+ )?;
Ok(nv)
}
@@ -287,7 +285,10 @@ async fn add_package_reqs_to_snapshot(
return Ok(snapshot);
}
- let result = snapshot.resolve_pending(package_reqs).await;
+ let pending_resolver = get_npm_pending_resolver(api);
+ let result = pending_resolver
+ .resolve_pending(snapshot, package_reqs)
+ .await;
api.clear_memory_cache();
let snapshot = match result {
Ok(snapshot) => snapshot,
@@ -297,7 +298,9 @@ async fn add_package_reqs_to_snapshot(
// try again
let snapshot = get_new_snapshot();
- let result = snapshot.resolve_pending(package_reqs).await;
+ let result = pending_resolver
+ .resolve_pending(snapshot, package_reqs)
+ .await;
api.clear_memory_cache();
// now surface the result after clearing the cache
result?
@@ -314,6 +317,21 @@ async fn add_package_reqs_to_snapshot(
}
}
+fn get_npm_pending_resolver(
+ api: &CliNpmRegistryApi,
+) -> NpmResolutionSnapshotPendingResolver<CliNpmRegistryApi> {
+ NpmResolutionSnapshotPendingResolver::new(
+ NpmResolutionSnapshotPendingResolverOptions {
+ api,
+ // WARNING: When bumping this version, check if anything needs to be
+ // updated in the `setNodeOnlyGlobalNames` call in 99_main_compiler.js
+ types_node_version_req: Some(
+ VersionReq::parse_from_npm("18.0.0 - 18.11.18").unwrap(),
+ ),
+ },
+ )
+}
+
fn populate_lockfile_from_snapshot(
lockfile: &mut Lockfile,
snapshot: &NpmResolutionSnapshot,