denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.42k stars 5.18k forks source link

deno vendor import map should keep the entries of the existing import map #16037

Open oscarotero opened 1 year ago

oscarotero commented 1 year ago

The import_map.json file generated by deno vendor doesn't contain the imports of the existing import_map.json. This makes script to fail because these import entries are missing.

As an example, Lume uses the following import map:

{
  "imports": {
    "lume/": "https://deno.land/x/lume@v1.11.4/"
  }
}

To vendor a Lume project, the script take 2 lume files and the _config.ts file:

deno vendor \
https://deno.land/x/lume@v1.11.4/task.ts \
https://deno.land/x/lume@v1.11.4/cli.ts \
./_config.ts

The vendor/import_map.json file doesn't include the lume/ import, so it fails.

Lume has a lume vendor command to run deno vendor and fix the new import_map.json file by adding automatically the missing imports (https://github.com/lumeland/lume/blob/f9866692391ed4d7500494b9d2b29de0921f9f26/cli/vendor.ts#L55-L63) but I think this is something that Deno should do.

dsherret commented 1 year ago

I think it maybe doesn't keep the entry because it can't find the import entry in the code. I'm not sure though.

oscarotero commented 1 year ago

I think it should keep all entries, even those not found in the code, because it may be present in other places. For example dynamic imports or, like in the Lume case, a task.