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/standalone/binary.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/standalone/binary.rs')
-rw-r--r-- | cli/standalone/binary.rs | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index 9ccb39e54..b71fda776 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -19,6 +19,7 @@ use deno_core::serde_json; use deno_core::url::Url; use deno_npm::registry::PackageDepNpmSchemeValueParseError; use deno_npm::resolution::SerializedNpmResolutionSnapshot; +use deno_npm::NpmSystemInfo; use deno_runtime::permissions::PermissionsOptions; use deno_semver::npm::NpmPackageReq; use deno_semver::npm::NpmVersionReqSpecifierParseError; @@ -343,8 +344,9 @@ pub struct DenoCompileBinaryWriter<'a> { deno_dir: &'a DenoDir, npm_api: &'a CliNpmRegistryApi, npm_cache: &'a NpmCache, + npm_resolution: &'a NpmResolution, npm_resolver: &'a CliNpmResolver, - resolution: &'a NpmResolution, + npm_system_info: NpmSystemInfo, package_json_deps_provider: &'a PackageJsonDepsProvider, } @@ -356,8 +358,9 @@ impl<'a> DenoCompileBinaryWriter<'a> { deno_dir: &'a DenoDir, npm_api: &'a CliNpmRegistryApi, npm_cache: &'a NpmCache, + npm_resolution: &'a NpmResolution, npm_resolver: &'a CliNpmResolver, - resolution: &'a NpmResolution, + npm_system_info: NpmSystemInfo, package_json_deps_provider: &'a PackageJsonDepsProvider, ) -> Self { Self { @@ -367,7 +370,8 @@ impl<'a> DenoCompileBinaryWriter<'a> { npm_api, npm_cache, npm_resolver, - resolution, + npm_system_info, + npm_resolution, package_json_deps_provider, } } @@ -488,13 +492,14 @@ impl<'a> DenoCompileBinaryWriter<'a> { .resolve_import_map(self.file_fetcher) .await? .map(|import_map| (import_map.base_url().clone(), import_map.to_json())); - let (npm_snapshot, npm_vfs, npm_files) = if self.resolution.has_packages() { - let (root_dir, files) = self.build_vfs()?.into_dir_and_files(); - let snapshot = self.resolution.serialized_snapshot(); - (Some(snapshot), Some(root_dir), files) - } else { - (None, None, Vec::new()) - }; + let (npm_snapshot, npm_vfs, npm_files) = + if self.npm_resolution.has_packages() { + let (root_dir, files) = self.build_vfs()?.into_dir_and_files(); + let snapshot = self.npm_resolution.serialized_snapshot(); + (Some(snapshot), Some(root_dir), files) + } else { + (None, None, Vec::new()) + }; let metadata = Metadata { argv: compile_flags.args.clone(), @@ -540,7 +545,10 @@ impl<'a> DenoCompileBinaryWriter<'a> { let registry_url = self.npm_api.base_url(); let root_path = self.npm_cache.registry_folder(registry_url); let mut builder = VfsBuilder::new(root_path); - for package in self.resolution.all_packages() { + for package in self + .npm_resolution + .all_system_packages(&self.npm_system_info) + { let folder = self .npm_resolver .resolve_pkg_folder_from_pkg_id(&package.pkg_id)?; |