36

Edge.js: Run Node apps inside a WebAssembly sandbox

Awesome project!

Dumb question: could you run this in frontend js using the browser's js engine and wasm environment similar to WebContainers? Maybe `fs` is just in-memory, and some things like forking are disabled. It'd be cool to have "nodejs" in the web!

28 minutes agowillquack

It’s not a dumb question at all.

And yes, it will allow running Node.js apps fully on the browser, in a way that’s more compatible than any other alternative!

Stay tuned!

8 minutes agosyrusakbary

Hi HN!

I'm Syrus, from Wasmer. We built Edge.js in a few weeks after different trials trying to bring Node.js to the Edge. We used AI and Codex heavily for this project, as otherwise the timeline would have spanned to a year plus to develop.

The summary of this announcement is that Edge.js:

  * Runs using WebAssembly when in `--safe` mode
  * It's fully compatible with Node.js (passing all their spec tests for non-VM modules)
  * It has a pluggable JS engine architecture: can work with V8, Javascript, SpiderMonkey, QuickJS, Hermes, etc.
Super happy to answer any questions you may have!
an hour agosyrusakbary

> * Runs using WebAssembly when in `--safe` mode

Why is safe mode opt-in?

28 minutes agojonny_eh

Maybe I’m just dense, but it says the fs module is fully supported, so what happens when I try to read a file from disk if the app is fully sandboxed?

an hour agolarsnystrom

Only the current working directory will be exposed/mounted to the runtime (we do this to facilitate the DX when running local files without requiring the user to add extra flags).

As a fun exercise, you can try reading process.cwd() from edge in --safe mode and without it.

an hour agosyrusakbary

It's a bit confusing.

Roughly:

* a refactor of Node.js, but using a standardized API for JS engine interop * Integration with the Wasmer CLI so it will run JS with v8 but, everything else in Webassembly

Interesting idea.

Could be a much lighter weight way to sandbox JS...

43 minutes agoalex_reg

We are so deep into the weeds that sometimes is hard for us to realize that maybe we are not explaining in the best terms.

What was the most confusing thing in the blogpost? I'd like to polish a bit more to make it clearer! Thanks a lot!

33 minutes agosyrusakbary

[dead]