From 37279e0b0a4300318da472bf0a8bdb894746537f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 20 Aug 2024 16:32:01 -0400 Subject: fix(add): error when config file contains importMap field (#25115) The "imports" field has higher precedence than "importMap", so we should error when `deno add` goes to add an `"imports"` field. Closes https://github.com/denoland/deno/issues/24264 Closes https://github.com/denoland/deno/pull/24478 --- cli/tools/registry/pm.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cli') diff --git a/cli/tools/registry/pm.rs b/cli/tools/registry/pm.rs index 52f3310ba..3cdef071f 100644 --- a/cli/tools/registry/pm.rs +++ b/cli/tools/registry/pm.rs @@ -289,6 +289,17 @@ pub async fn add( _ => bail!("Failed updating config file due to no object."), }; + if obj.get_string("importMap").is_some() { + bail!( + concat!( + "`deno add` is not supported when configuration file contains an \"importMap\" field. ", + "Inline the import map into the Deno configuration file.\n", + " at {}", + ), + config_specifier + ); + } + let mut existing_imports = config_file.existing_imports()?; let is_npm = config_file.is_npm(); -- cgit v1.2.3