Open renhiyama opened 1 year ago
does nodejs/bun support U'rl imports now?
They dont, but if you consider third party implementations, they technically can still consume url imports (if the third party works by downloading the scripts and importing them to nodejs/bun, similar to what you can see in deno.)
Nextjs has URL imports in testing (https://esm.vercel.app/)
And I'm working on @reejs/imports
(& reejs
pkg's cli based url imports downloader) npm package to achieve the same thing that deno does. So I thought it would be cool if there's a standard user agent we could use for stability usage with esm.sh so based on what runtime user is using, we could easily send it to esm.sh servers and get the required build ;) without using ?target query.
maybe just similar to deno: Node/16
, what do you think?
I was not sure whether this implemented by esm.sh. hopefully it is Bun/x
for bun
currently the server use es2022
as the build target for deno, it's good for bun too?
It would be better to use the node target for bun ;p bun tries to work with nodejs, and not like deno where you need to rewrite your whole nodejs project to make it compatible with deno's url imports and security flags that only deno has. Deno also has browser like environment, so most of the code that are made for nodejs has some more polyfills added for deno. it would make more sense to use nodejs' native modules instead of those for more efficiency. Not to mention, you can maybe go forward and instead of not using nodejs as target, add a new target as bun; there are some Bun specific APIs and features that are only available in Bun and have huge performance improvements over Node implementations. You might still need to have node:path
and other native node module support for Bun target though.
As far as I know, esm.sh checks whether the user agent is deno or not, and then automatically uses the deno target, same for browsers, so what about nodejs? Also anything about bun? (If a third party library can consume URL imports in nodejs, bun can consume too.)