Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
0xdavid7 opened this issue Sep 14, 2023 · 2 comments

Comments

@0xdavid7
Copy link

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! 🤩

@cawfree
Copy link
Owner

cawfree commented Nov 3, 2023

Hey, thanks for reaching out.

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

@lxh1579419223
Copy link

Has this feature made any progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants