1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

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
This commit is contained in:
David Sherret 2024-08-20 16:32:01 -04:00 committed by GitHub
parent a7c002ae63
commit 37279e0b0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 0 deletions

View file

@ -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();

View file

@ -0,0 +1,5 @@
{
"args": "add jsr:@denotest/add",
"output": "add.out",
"exitCode": 1
}

View file

@ -0,0 +1,2 @@
error: `deno add` is not supported when configuration file contains an "importMap" field. Inline the import map into the Deno configuration file.
at file:///[WILDLINE]/deno.json

View file

@ -0,0 +1,3 @@
{
"importMap": "./import_map.json"
}

View file

@ -0,0 +1 @@
{}