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/tsc | |
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/tsc')
-rw-r--r-- | cli/tsc/mod.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index b296bf9c6..e0ea22cd9 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -559,7 +559,9 @@ fn op_load(state: &mut OpState, args: Value) -> Result<Value, AnyError> { Module::Npm(_) | Module::Node(_) => None, Module::External(module) => { // means it's Deno code importing an npm module - media_type = MediaType::from(&module.specifier); + let specifier = + node::resolve_specifier_into_node_modules(&module.specifier); + media_type = MediaType::from(&specifier); let file_path = specifier.to_file_path().unwrap(); let code = std::fs::read_to_string(&file_path).with_context(|| { @@ -731,9 +733,10 @@ fn resolve_graph_specifier_types( Some(Module::External(module)) => { // we currently only use "External" for when the module is in an npm package Ok(state.maybe_npm_resolver.as_ref().map(|npm_resolver| { + let specifier = + node::resolve_specifier_into_node_modules(&module.specifier); NodeResolution::into_specifier_and_media_type( - node::url_to_node_resolution(module.specifier.clone(), npm_resolver) - .ok(), + node::url_to_node_resolution(specifier, npm_resolver).ok(), ) })) } |