react-native-webassembly icon indicating copy to clipboard operation
react-native-webassembly copied to clipboard

Request for Adding the "compile" function support in "react-native-webassembly"

Open 0xdavid7 opened this issue 2 years ago • 2 comments

Issue Description

I am trying to rebuild ffjavascript to run on React Native, and I need the compile function to be supported in react-native-webassembly.

Currently, the WebAssembly in browser engine supports the compile function, which accepts a bytes parameter and returns a Promise<Module>.

  function compile(bytes: BufferSource): Promise<Module>;
    /** [MDN Reference](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming) */

I would like to request support for this function in react-native-webassembly to replace the following code in my project:

// threadman.js

import * as WebAssembly from "react-native-webassembly";

...

export default async function buildThreadManager(wasm, singleThread) {
  const tm = new ThreadManager();
  tm.memory = new WebAssembly.Memory({ initial: MEM_SIZE });

  // This line uses the compile function
  const wasmModule = await WebAssembly.compile(wasm.code);

  tm.instance = await WebAssembly.instantiate(wasmModule, {
    env: {
      memory: tm.memory,
    },
  });
}

Thank you so much! 🤩

0xdavid7 avatar Sep 14 '23 14:09 0xdavid7

Hey, thanks for reaching out.

Interesting. Um. Hm. Yeah we can probably do this.

cawfree avatar Nov 03 '23 00:11 cawfree

Has this feature made any progress

lxh1579419223 avatar Jan 04 '24 09:01 lxh1579419223