diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-05-17 17:38:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 17:38:50 -0400 |
commit | 41f618a1df6bb8c66d7968ac64456139b9f4c197 (patch) | |
tree | dbcc67e009cf70099be82ea3774669e8aefc6023 /cli/npm/resolution.rs | |
parent | ad223362451688c13a4441563210f58bdb046a78 (diff) |
fix(npm): improved optional dependency support (#19135)
Note: If the package information has already been cached, then this
requires running with `--reload` or for the registry information to be
fetched some other way (ex. the cache busting).
Closes #15544
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/npm/resolution.rs')
-rw-r--r-- | cli/npm/resolution.rs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/cli/npm/resolution.rs b/cli/npm/resolution.rs index edc7ec647..3e9438ffa 100644 --- a/cli/npm/resolution.rs +++ b/cli/npm/resolution.rs @@ -23,6 +23,7 @@ use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot; use deno_npm::NpmPackageCacheFolderId; use deno_npm::NpmPackageId; use deno_npm::NpmResolutionPackage; +use deno_npm::NpmSystemInfo; use deno_semver::npm::NpmPackageNv; use deno_semver::npm::NpmPackageNvReference; use deno_semver::npm::NpmPackageReq; @@ -237,12 +238,21 @@ impl NpmResolution { Ok(nv) } - pub fn all_packages(&self) -> Vec<NpmResolutionPackage> { - self.snapshot.read().all_packages() + pub fn all_system_packages( + &self, + system_info: &NpmSystemInfo, + ) -> Vec<NpmResolutionPackage> { + self.snapshot.read().all_system_packages(system_info) } - pub fn all_packages_partitioned(&self) -> NpmPackagesPartitioned { - self.snapshot.read().all_packages_partitioned() + pub fn all_system_packages_partitioned( + &self, + system_info: &NpmSystemInfo, + ) -> NpmPackagesPartitioned { + self + .snapshot + .read() + .all_system_packages_partitioned(system_info) } pub fn has_packages(&self) -> bool { @@ -322,7 +332,7 @@ fn populate_lockfile_from_snapshot( .as_serialized(), ); } - for package in snapshot.all_packages() { + for package in snapshot.all_packages_for_every_system() { lockfile .check_or_insert_npm_package(npm_package_to_lockfile_info(package))?; } @@ -330,13 +340,13 @@ fn populate_lockfile_from_snapshot( } fn npm_package_to_lockfile_info( - pkg: NpmResolutionPackage, + pkg: &NpmResolutionPackage, ) -> NpmPackageLockfileInfo { let dependencies = pkg .dependencies - .into_iter() + .iter() .map(|(name, id)| NpmPackageDependencyLockfileInfo { - name, + name: name.clone(), id: id.as_serialized(), }) .collect(); |