Repository navigation
Host API compatibility (e.g. Node.js) #1428
Replies: 2 comments 5 replies
|
I looked in to Wasmer's edge.js. Couldn't get it to build for a while wasmerio/edgejs#70. I don't think I was able to create a Native Messaging host using Node.js "compatibility" I think was part of your goal, correct? To import packages from NPM? I'd go with Deno and Bun API's. Deno for WHATWG Streams and Web API's, Bun for Bun Shell and build. But really, ECMA-262 needs to write out I/O, so as to not add yet more implementations, or not. See, WASI has a concept of cli, io, stin, stdout, fd_read, fd_write. ECMA-262 has no such interfaces. So, when I ask the StarlingMonkey bytecodealliance/StarlingMonkey#314, ComponentizeJS bytecodealliance/ComponentizeJS#342, ByteCode Alliance folks - how exactly are you reading STDIN in the Component Model based on JavaScript input, I could get an answer pointing to a formal, canonical specification. How is that WIT actually written in JavaScript? You wrote it one way, componentize-qjs does it a different way andreiltd/componentize-qjs#2 that I couldn't get to work as a Native Messaging host. That's all good. I use AssemblyScript, Javy, js2wasm, and qjs-wasi.wasm. With qjs-wasi.wasm, we get QuickJS NG, the engine. |
|
Regarding compatibility I would first focus on NPM compatibility in the sense that an NPM package can be compiled to .wasm and used as a drop in replacement in the original host like in a browser or Node.js host as a baseline to start with. This makes the path shorter to get something working and also allows for hands on experience with the original APIs before swapping them against API compatible alternative implementations like for WASI hosts. I have not yet tried out Edge.js myself and indeed I am curious how a portable definition of a host API would look like and if it should be in WIT or typescript like I currently do for the Web APIs. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
@guest271314 posted on #389 and suggested to move this here:
My take on Node.js compatibility is like every other host API is that we should consider these imports that anyone can satisfy in the way they see fit:
It could be a real Node.js host just passing through its APIs or an adapter shim mapping to Deno APIs, using Wasmer's Edge.js WASI implementation - or what you mention above.
So in a way this could be considered orthogonal to core js2wasm and even be compatible with other projects similar to js2wasm (.js or .ts based variants).
I think this is where a .wit world could be the natural fit for a specification of the exact Node.js APIs that Edge.js might already satisfy, but haven't looked into it yet.
While my focus right now is getting js2wasm off the ground, just saying how this would click together later is exactly a good example of the modularity WebAssembly brings to the table where you can just swap out implementations as long as they are semantically consistent - at least that's the dream.
It will be interesting to see if this will be realized, and this is the right place to discuss bigger ideas to shape, expand and share a bigger vision.
All reactions