diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-02-24 19:35:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-24 19:35:43 -0500 |
commit | 033b70af19300a4e34dcf19ab0031245bfc19625 (patch) | |
tree | ebcd8e9ebd85a974c9845af0291ab3bdb9765704 /cli/cache/mod.rs | |
parent | 5683daf1aa1c01f5f4d01879d6ce054b0922faf6 (diff) |
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
Diffstat (limited to 'cli/cache/mod.rs')
-rw-r--r-- | cli/cache/mod.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs index 90f88530f..a962538b7 100644 --- a/cli/cache/mod.rs +++ b/cli/cache/mod.rs @@ -2,7 +2,6 @@ use crate::errors::get_error_class_name; use crate::file_fetcher::FileFetcher; -use crate::util::fs::canonicalize_path; use deno_core::futures; use deno_core::futures::FutureExt; @@ -108,12 +107,8 @@ impl Loader for FetchCacher { // is in a node_modules dir to avoid needlessly canonicalizing, then compare // against the canonicalized specifier. if specifier.path().contains("/node_modules/") { - let specifier = specifier - .to_file_path() - .ok() - .and_then(|path| canonicalize_path(&path).ok()) - .and_then(|path| ModuleSpecifier::from_file_path(path).ok()) - .unwrap_or_else(|| specifier.clone()); + let specifier = + crate::node::resolve_specifier_into_node_modules(specifier); if specifier.as_str().starts_with(node_modules_url.as_str()) { return Box::pin(futures::future::ready(Ok(Some( LoadResponse::External { specifier }, |