-
Notifications
You must be signed in to change notification settings - Fork 412
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
I want to build wasm for Deno. #672
Comments
|
@kahirokunn is there |
related denoland/deno#1325 |
@kahirokunn in order to run wasm-packed wasm, you'll need to require the js wrapper generated by wasm-bindgen. can deno load JS? |
fyi Deno has resolved the original issue posted above and have also recently just introduced WASM imports (should be very similar to Node.js's import { exportedFunc1, exportedFunc2 } from "./my.wasm"; If (module
(import "./wasm-dep.js" "jsFn" (func $jsFn (result i32)))
(import "http://127.0.0.1:4545/cli/tests/051_wasm_import/remote.ts" "jsRemoteFn" (func $jsRemoteFn (result i32)))
) with corresponding local/remote file set up with correct named exports. |
I use below for a while cargo generate --git https://github.com/rustwasm/wasm-pack-template -n myproject
cd myproject
# deno has not alert but has console.log.
sed -i -e "s/fn alert(s: &str);/#[wasm_bindgen(js_namespace = console, js_name = log)] fn alert(s: \\&str);/" src/lib.rs
wasm-pack build --target web --out-name index
# deno hasn't supported fetch('file:// ...') yet.
sed -i -e "s#input = import\\.meta\\.url\\.replace(/\\\\\\.js$/, '_bg\\.wasm');#input = import.meta.url.replace(/\\\\.js$/, '_bg.wasm'); if ('undefined' !== typeof Deno) input = new WebAssembly.Module(await Deno.readFile(new URL(input).pathname));#" pkg/index.js
echo "import * as pkg from './pkg/index.js'
await pkg.default()
pkg.greet()" >| app.js
deno run --allow-read app.js |
Just for future references of those who are still a little confused and end up in this opened issue. To build for deno just build for web: The only problem at the moment is that Deno doesn't support fetch for local files, and the web targeted build will try to get the example: import init, {greet} from "./pkg/greet.js";
await init(Deno.readFile('./pkg/greet_bg.wasm'));
greet(); |
Fixed in v0.11.0. |
💡 Feature description
I want to build wasm for Deno.
https://github.com/denoland/deno
I try write rust and do wasm-pack.
And then I got .wasm file, I put it file on the Deno.
But the wasm file never work....(´;ω;`)
💻 Basic example
The text was updated successfully, but these errors were encountered: