summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-10-03 23:26:42 +0200
committerGitHub <noreply@github.com>2022-10-03 23:26:42 +0200
commitfde938116d8b44a87579d6b65dcba79cbe988809 (patch)
treef1c71adbb3ba536ed393f0bdd0d20759e969e656 /cli/main.rs
parent5b097fd7e5224db6de65847a604f5c60a93667a0 (diff)
feat(unstable): add support for npm specifier cli arguments for 'deno cache' (#16141)
This commit adds support for npm specifier in "deno cache" subcommand. ``` $ deno cache --unstable npm:vite npm:chalk https://deno.land/std/http/file_server.ts ``` Besides downloading requested npm package(s), it will also download necessary code from "std/node/".
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 2ad5c83c0..358f12b17 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -393,6 +393,18 @@ async fn load_and_type_check(
for file in files {
let specifier = resolve_url_or_path(file)?;
+
+ // TODO(bartlomieju): in the future (after all relevant deno subcommands
+ // have support for npm: specifiers), it would be good to unify this code
+ // in `ProcState::prepare_module_load`.
+ if let Ok(package_ref) = NpmPackageReference::from_specifier(&specifier) {
+ ps.npm_resolver
+ .add_package_reqs(vec![package_ref.req.clone()])
+ .await?;
+ ps.prepare_node_std_graph().await?;
+ continue;
+ }
+
ps.prepare_module_load(
vec![specifier],
false,