deno_cache icon indicating copy to clipboard operation
deno_cache copied to clipboard

Support "npm:" scheme

Open tjosepo opened this issue 2 years ago • 2 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.

tjosepo avatar Sep 10 '23 15:09 tjosepo

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:[email protected]). 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...

https://github.com/oakserver/oak/issues/660#issuecomment-2171007494

garethj2 avatar Jun 14 '24 12:06 garethj2

I'm using Rollup in my Deno project, and it sure would be nice to be able to use Deno's npm: specifiers.

It looks like there's some promising code under the name es_build_loader, and this fork: https://jsr.io/@duesabati/esbuild-deno-plugin

dgreensp avatar Jan 31 '25 01:01 dgreensp