wasmedge-quickjs icon indicating copy to clipboard operation
wasmedge-quickjs copied to clipboard

Support all node.js APIs

Open juntao opened this issue 2 years ago • 3 comments

We are tracking the progress in the WasmEdge repo.

https://github.com/WasmEdge/WasmEdge/issues/1535

juntao avatar Jun 10 '22 19:06 juntao

Do you intend to also support the built-in WebAssembly object:

import * as std from 'std'

let wasmBuffer = std.loadFile('target/wasm32-unknown-unknown/release/node.wasm');
WebAssembly.instantiate(wasmBuffer).then(wasmModule => {
  const { add } = wasmModule.instance.exports;
  const sum = add(5, 6);
  console.log(sum); 
});

mraszyk avatar Jun 12 '22 16:06 mraszyk

Hmm. Our goal is to run JS inside Wasm. When the Wasm modules spec is ready, we could allow JS programs to call from one WasmEdge instance to another one. But it is not currently a priority unless you want to work on it. :)

juntao avatar Jun 12 '22 17:06 juntao

I have a related question: currently the module federation backend framework (written largely in JS and running on Node.js) streams code directly from its source repo, compiles and loads into memory (both JS and Wasm). Naturally, the JS framework uses the above wasm APIs. The plan is to port the framework to QuickJS to support a wasm runtime (for serverless, embedded). Or to compile Deno to wasm and port to that (if possible - haven't investigated). If there is a better way to do this, I'm all in. Otherwise, I will help implement the above APIs. Timeline would be starting around October.

tysonrm avatar Jun 17 '22 13:06 tysonrm