esm.sh
esm.sh copied to clipboard
CLI assumes `import_map.json` even if `deno.json` has `imports`
In a project using the imports
key in deno.json
/deno.jsonc
instead of using importMap
, the CLI still tries to use import_map.json
instead. Running it always creates an import_map.json
(whether you use add
, update
, or remove
-- the last two just create an empty import map), Deno won't use an external import map if there's an imports
(or scopes
) section in the deno.json
/deno.jsonc
file.
Instead, it should look to see if imports
is being used in deno.json
, and manage entries in that section rather than import_map.json
. If the file is a deno.jsonc
, it should preserve comments.
As I mentioned in #686, I've found the jsonc-parser
package that could be used for this. If I get time, would a PR using that to manage imports be welcome?
I would recommend using the Deno standard library's jsonc
parser (https://github.com/denoland/deno_std/tree/main/jsonc).
@lino-levan The problem with that is that it just discards comments. See more on this in the other linked issue: #686. :-)
@farsightsoftware does the parser of the std jsonc module discard comments or the stringifier?
Can you add an example to this Issue I made on the deno std lib repo?
https://github.com/denoland/deno_std/issues/3502
I'm currently a little short on time, otherwise I'd check it myself. Maybe you haven an example already?
(I've replied here.)