jspm / jspm-cli

ES Module Package Manager
https://jspm.org
Apache License 2.0
3.79k stars 272 forks source link

Question: Deno compatibility roadmap #2486

Closed fusionstrings closed 1 year ago

fusionstrings commented 5 years ago

It's so cool that JSPM auto generates importmaps. Since Deno supports importmaps, it's natural to leverage jspm generated maps with Deno.

When I tried it, I quickly stumbled across nodejs environment specific codes, which is incompatible to Deno. One such issue is https://github.com/denoland/deno/issues/650.

I know that the issue is with the code and may be beyond goal and scope of JSPM or Deno. May be https://github.com/denoland/deno/issues/2644 is a solution for future from Deno's perspective. Since JSPM takes care of node js compatibility via DEW transformation of CJS, is it a possibility to transform the code for Deno compatibility? What should be a reasonable expectation from JSPM in this context?

guybedford commented 5 years ago

Thanks for opening this discussion, I've responded on the Deno thread there.

guybedford commented 5 years ago

Re Deno support in the CLI, the way to support this would be through a Deno resolver hook to enable jspm_packages resolution, just like we use the resolver hook in Node.js. I don't know if Deno provides anything like this though.

fusionstrings commented 5 years ago

Thanks for your positive response. I am not quite sure what did you mean by deno resolver. Did you mean identifying uniquely if it's deno environment?

guybedford commented 5 years ago

I mean a way to hook into the resolution algorithm in Deno itself. Just like we do in Node.js using the --loader.

fusionstrings commented 5 years ago

I see, the original wish behind this issue is to support deno resolution through importmaps. The challenge I expected was to generate the maps which is compatible with deno as well as transforming npm / jspm packages for non browser targets, which until now has been node only.

guybedford commented 5 years ago

Right, I always just consider runtime integrations from the bottom-up, but the import map integration would basically be a --deno flag for jspm map, where under that environment is uses the Deno Node.js wrappers for fs etc, exactly as in https://github.com/denolib/node. We would effectively build this into the jspm corelibs (say as a denolibs folder in https://github.com/jspm/jspm-core).