3 ms·
There is already a system for building a NPM node package from a Deno package, called dnt (deno to node). It's maintained by some Deno team members. Here's a bl
by jitl 4y ago
There is already a system for building a NPM node package from a Deno package, called dnt (deno to node). It's maintained by some Deno team members. Here's a blog post they wrote about porting "Oak" (a deno HTTP server framework) to Node: https://deno.com/blog/dnt-oak https://deno.com/blog/dnt-oak
The nice thing about Deno conceptually, is that it's much more similar to the browser platform than node is. It uses ES6 only, has things like `fetch` built-in by default, and generally follows browser standards around interfaces like Request, Response, etc. Instead of needing a complicated build process to make Node code work on the browser, now we have a complicated build process to make Deno/Browser code work on Node. ¯\_(ツ)_/¯
- capableweb 4y agoNot to take away from the rest of your message, I thought you wanted to get up to speed on that `fetch` is now available in nodejs core since version 17 or something like that (think it got included early this year).
- jitl 4y agoI think this requires the `--experimental-fetch` command-line argument (per https://nodejs.org/tr/blog/release/v17.5.0/ https://nodejs.org/tr/blog/release/v17.5.0/), so I don't think it qualifies as "by default".
- wging 4y agoThat's an old blog post; the current release is 18.4.0, which supports `fetch` without a command-line argument. You do get this warning the first time it's invoked, though: (node:340760) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created) (some later blog posts that mention fetch being enabled-by-default and in the global scope are https://nodejs.org/en/blog/announcements/v18-release-announce/ https://nodejs.org/en/blog/announcements/v18-release-announc... and https://nodejs.org/en/blog/release/v18.0.0/ https://nodejs.org/en/blog/release/v18.0.0/)
- wdb 4y agoYeah, but you could use `undici`-package for older Node version as it is being used to provide this experimental Fetch in Node 17+
- the_gipsy 4y agoWhat about using an npm package in deno?
- wperron 4y agoHas been possible (and surprinsingly easy) for a while through CDNs like skypack or esm.sh
- yencabulator 4y agoIt's possible when it happens to work. https://github.com/esm-dev/esm.sh/issues?q=is%3Aissue+is%3Aopen+Failed+to+import https://github.com/esm-dev/esm.sh/issues?q=is%3Aissue+is%3Ao...
- the_gipsy 4y agoSo deno runs JS? I thought it ran exclusively typescript.
- whostolemyhat 4y agoJavascript is Typescript - TS is a superset of JS, so valid JS is valid TS, although you'd almost certainly get lint errors in dev complaining about lack of types.
- melony 4y agoCan the same build pipelines be reused for CF/Fastly workers? The DX for workers is horrible with multiple buggy Wrangler implementations and zero observability into deployed workers.