Replies: 2 comments
-
What is you |
Beta Was this translation helpful? Give feedback.
0 replies
-
@jihuayu but I want to run the function using js code, is that possible, the code works with mjs file and wasm file. import mod from './index.wasm'; // Import WASM module
export default {
async fetch(request, env, ctx) {
try {
const instance = await WebAssembly.instantiate(mod);
const wasmModule = await instance.exports.msg();
return new Response(`Success: ${wasmModule}`);
} catch (error) {
return new Response(`Error: ${error.message}`, { status: 500 });
}
}
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
There's
hello-wasm
sample, but it seems not work correctly.Basically we can call Wasm from JavaScript via wrangler, so I did try to port this example to workerd.
I copy the
simple.wasm
generated by wat2wasm to the same folder of README projectAnd change the
hello.js
to:But got error when running:
Beta Was this translation helpful? Give feedback.
All reactions