mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(compile): show an error when using npm specifiers (#16430)
Closes #16427
This commit is contained in:
parent
a0d10efbb1
commit
678ac5757b
2 changed files with 24 additions and 0 deletions
16
cli/main.rs
16
cli/main.rs
|
@ -76,6 +76,7 @@ use crate::tools::check;
|
||||||
|
|
||||||
use args::CliOptions;
|
use args::CliOptions;
|
||||||
use deno_ast::MediaType;
|
use deno_ast::MediaType;
|
||||||
|
use deno_core::anyhow::bail;
|
||||||
use deno_core::error::generic_error;
|
use deno_core::error::generic_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::JsError;
|
use deno_core::error::JsError;
|
||||||
|
@ -256,6 +257,21 @@ async fn compile_command(
|
||||||
|
|
||||||
graph.valid().unwrap();
|
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 parser = ps.parsed_source_cache.as_capturing_parser();
|
||||||
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
|
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
|
||||||
|
|
||||||
|
|
|
@ -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)> {
|
fn env_vars_no_sync_download() -> Vec<(String, String)> {
|
||||||
vec![
|
vec![
|
||||||
("DENO_NODE_COMPAT_URL".to_string(), util::std_file_url()),
|
("DENO_NODE_COMPAT_URL".to_string(), util::std_file_url()),
|
||||||
|
|
Loading…
Reference in a new issue