diff --git a/cli/main.rs b/cli/main.rs index 1fb942963d633..e9fbeba5b3bdd 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -76,6 +76,7 @@ use crate::tools::check; use args::CliOptions; use deno_ast::MediaType; +use deno_core::anyhow::bail; use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::error::JsError; @@ -256,6 +257,21 @@ async fn compile_command( graph.valid().unwrap(); + // at the moment, we don't support npm specifiers in deno_compile, so show an error + let first_npm_specifier = graph + .specifiers() + .values() + .filter_map(|r| match r { + Ok((specifier, kind, _)) if *kind == deno_graph::ModuleKind::External => { + Some(specifier.clone()) + } + _ => None, + }) + .next(); + if let Some(npm_specifier) = first_npm_specifier { + bail!("npm specifiers have not yet been implemented for deno compile (https://github.com/denoland/deno/issues/15960). Found: {}", npm_specifier) + } + let parser = ps.parsed_source_cache.as_capturing_parser(); let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?; diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 8fa79d06cdc96..722cbdb39186b 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -711,6 +711,14 @@ fn ensure_registry_files_local() { } } +itest!(compile_errors { + args: "compile -A --quiet --unstable npm/esm/main.js", + output_str: Some("error: npm specifiers have not yet been implemented for deno compile (https://github.com/denoland/deno/issues/15960). Found: npm:chalk@5\n"), + exit_code: 1, + envs: env_vars(), + http_server: true, +}); + fn env_vars_no_sync_download() -> Vec<(String, String)> { vec![ ("DENO_NODE_COMPAT_URL".to_string(), util::std_file_url()),