denoland / deno_cache_dir

Deno CLI's module cache

Home Page:https://jsr.io/@deno/cache-dir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support "npm:" scheme

tjosepo opened this issue · comments

Currently, deno_cache only supports URL imports.

The only way to add an npm: module to Deno's cache is to:

  • Import it with a static import. Not ideal since it forces you to execute the package's code which does not make sense for front-end packages.
  • Use a package.json file.

It's also difficult to get the source code of npm: modules, unless the "nodeModulesDir" option is enabled.

Supporting npm: scheme or finding alternative ways to cache and obtain the source code of npm: modules that don't rely on the node_modules folder or the package.json file could enable better Deno-first tooling.

I've just stumbled across this as well.

I've been trying to build an application that uses the popular oak web server. The latest version of oak has an npm dependency (npm:path-to-regexp@6.2.1). This causes deno emit (and anything that requires a cache) to fail...

https://jsr.io/@oak/oak/16.1.0/deps.ts

Considering the widespread support for jsr and npm, I've very surprised this has been left out here.

Also note there doesn't appear to be any support for the node scheme either.

For more information, please see this issue created for Oak. This issue also covers dynamic imports...

oakserver/oak#660 (comment)