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!As a fun exercise, you can try reading process.cwd() from edge in --safe mode and without it.
need docs
Why is safe mode opt-in?
I think this is a cool demo for you to show, at least in my mind this might be a little mind blowing + maybe a db?
I know there are wasm dbs availble that are very light, but so that maybe it's a plus to consider.
I think the fact that WASIX is much more mature now have helped to increase development speeds quite a bit!
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...
What was the most confusing thing in the blogpost? I'd like to polish a bit more to make it clearer! Thanks a lot!
First, I could not find usage examples on the edgejs.org page and the docs link points to the node docs, why?
If I head to github, there are some usage examples, but they confuse me more.
The first example: $ edge server.js led me to think that this is a node replacement that runs in a webassembly sandbox, so completely isolated. But why the need of --safe then? What's the difference between using it and not using it?
But the next examples creates more confusion to me: $ edge node myfile.js $ edge npm install $ edge pnpm run dev
What is this doing? I thought that edge was a node replacement, interpreting and running javascript files, but it's now running executables (node, npm)... what is that? What happens when I run npm install... where does it install files? What's the difference between running edge node myfile.js and edge myfile.js?
Hope this helps.
This was intentional, as a demonstration that Edge and Node should not diverge a bit. You should be able to replace `node` with `edge` in your terminal and have things running, so that's why we point to the Node.js docs.
> But why the need of --safe then? What's the difference between using it and not using it?
Edge.js currently runs without a sandbox by default. The main reason for this is two fold: native currently performs a bit better than with the Wasm sandbox (about 10-20% better), and because we wanted to polish more the Wasm integration before offering it as default.
> $ edge pnpm run dev > What is this doing?
This is making the `node` alias available for anything that you put after edge. This allows pnpm to use the edge `node` alias instead of your platform node.
Things will be installed as usual, in your `node_modules` directory
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!
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!
I can see where that's going.
Awesome. I want to msg. you on LinkedIn but can't.
Currently it supports Node, but we plan to add Python, Ruby, git, and more.
You can see it in action in this demo: https://vitedemo.browserpod.io
More info here: https://labs.leaningtech.com/blog/browserpod-10
Ah and kudos to Syrus and his team for this release. Edge.js's architecture seems to have many similarities with BrowserPod. I see it as proof that we are both going in the right direction!
It should probably take a few hours with AI to get a demo for it :)
Question regarding the pluggable js engine: I have an electron app where I'm currently using QuickJS to run LLM-generated code. Would edge.js be able (theoretically) to use electron's v8 to get a "sanboxed within electron" execution environment?
We actually believe Edge.js will a great use case for LLM-generated code.
For personal computer, people worried about the spin up time of docker? I think that is more of a tooling issue where you spin up one instance and run multiple jobs.
What am I missing? What are actually real use cases where this would be better?
I know of the extism project and played around with it in elixir, but I'm looking to have CF Workers DX with as little operational complexity as possible for many silly pet projects.
(A.K.A. are we IBM 360 yet?)
Being able to import from "https://my-vpn.com/mypackage@1.2.3" or "npm:package@1.2.3" and just running code without having to worry about scaffolding node_modules makes sandboxing code much easier
What is the lifecycle of the sandbox? Can we pause, step-by-step, pause and resume executed code?