-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
WASM Support #1325
Comments
code example(wasm.js): // @ts-nocheck
const wasm = new Uint8Array(`
00 61 73 6d 01 00 00 00 01 0c 02 60 02 7f 7f 01
7f 60 01 7f 01 7f 03 03 02 00 01 07 10 02 03 61
64 64 00 00 06 73 71 75 61 72 65 00 01 0a 13 02
08 00 20 00 20 01 6a 0f 0b 08 00 20 00 20 00 6c
0f 0b`.trim().split(/[\s\r\n]+/g).map(str => parseInt(str, 16)))
console.log('compile start')
const p = WebAssembly.compile(wasm)
console.log('compile end')
console.log(p)
p.then(module => {
const instance = new WebAssembly.Instance(module)
const { add, square } = instance.exports
console.log('2 + 4 =', add(2, 4))
console.log('3^2 =', square(3))
console.log('(2 + 5)^2 =', square(add(2 + 5)))
}).catch(err => {
console.error(err)
}).finally(() => {
console.log('all done')
}) use node.js:
use deno:
|
Yes. It will be easily approachable once #975 (https://github.com/ry/deno/tree/esm) lands. I plan to do this work myself. In particular I plan to support them as first-class modules, cacheable/loadable from http like other code. |
@ry can you say more about what you have in mind for "first-class module" support? Do you mean that you would be able to import them using ESM syntax?
Or would it match something closer to web & node's current support, where you need to fetch/read the file and then instantiating it manually? |
I believe the actual problem is that We might need to take care of this if we are planning to refactor the event loop some time |
Actually it seems that there is actually no attempt to compile the module, or that the attempt is never even present in the microtask queue (an infinite loop of |
An experimental branch of Node has started with the Also see https://github.com/WebAssembly/esm-integration/tree/master/proposals/esm-integration about the current standardization process |
Resolved by #1677 |
@kitsonk actually not yet, |
The title of the issue is a bit mis-leading, I think we are talking about support WebAssembly as modules? Either way, it isn't clear to me what we need to do here beyond what was delivered in #1677 except supporting |
It'd be great to have a working documented example like this for deno: https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm |
Anything about WASI? |
From feedback by @justjavac :
The text was updated successfully, but these errors were encountered: