Skip to content

Commit

Permalink
fix(compile): show an error when using npm specifiers (denoland#16430)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 26, 2022
1 parent a0d10ef commit 678ac57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())?;

Expand Down
8 changes: 8 additions & 0 deletions cli/tests/integration/npm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 678ac57

Please sign in to comment.