1

How does one vendor a npm package in deno?

import_map.json:

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

Lume has some npm dependencies, like https://registry.npmjs.org/markdown-it/-/markdown-it-13.0.0.tgz.

deno.jsonc:

{
    "importMap": "import_map.json",
} 

dev_deps.ts:

export * as lume from "https://deno.land/x/lume@v1.12.1/mod.ts";

command:

$ deno vendor --force --unstable dev_deps.ts
# ...
Download https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.3.tgz
# ...
thread 'main' panicked at 'Could not find local path
 for npm:markdown-it-attrs@4.1.3', cli/tools/vendor/mappings.rs:138:11

I tried adding export * as ma from "npm:markdown-it-attrs"; to dev_depts.ts, but it did nothing.

I found the following issue on github.

Maybe this issue does have something to do with it.

I didn't find anything about how to resolve the problem in the official deno documentation and the lume documentation.

anick
  • 111
  • 3

1 Answers1

2

Unfortunately, currently you cannot use import_map in your Deno project if your goal is to publish a module that aims to be used in other applications, simply because you don't handle the way deno runtime will start.

From the application point of view, the deno run command cannot search every import_map configurations in your dependencies and handle them properly.

The import_map feature should be used only at end application level. The fallback is to use by onvention a deps.ts source file to centralize all your dependencies.