mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(npm): lazily install package.json dependencies only when necessary (#17931)
This lazily does an "npm install" when any package name matches what's found in the package.json or when running a script from package.json with deno task. Part of #17916 Closes #17928
This commit is contained in:
parent
5683daf1aa
commit
033b70af19
21 changed files with 205 additions and 67 deletions
|
@ -19,7 +19,6 @@ use deno_runtime::deno_node::RequireNpmResolver;
|
|||
use global::GlobalNpmPackageResolver;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
@ -224,19 +223,6 @@ impl NpmPackageResolver {
|
|||
self.resolution.has_packages()
|
||||
}
|
||||
|
||||
/// Adds the package reqs from a package.json if they exist.
|
||||
pub async fn add_package_json_deps(
|
||||
&self,
|
||||
maybe_package_json_deps: Option<&BTreeMap<String, NpmPackageReq>>,
|
||||
) -> Result<(), AnyError> {
|
||||
if let Some(deps) = maybe_package_json_deps {
|
||||
let mut package_reqs = deps.values().cloned().collect::<Vec<_>>();
|
||||
package_reqs.sort(); // deterministic resolution
|
||||
self.add_package_reqs(package_reqs).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Adds package requirements to the resolver and ensures everything is setup.
|
||||
pub async fn add_package_reqs(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue