mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
Convert all examples to using wasm-pack
This commit migrates all our examples to using `wasm-pack build` to compile their code and run `wasm-bindgen`. This should make it a bit easier to understand the examples as there's less to follow during the build step. Webpack projects are all using `@wasm-tool/wasm-pack-plugin` as well so the build step is simple `npm run serve`. Other examples which retain `build.sh` are just using `wasm-pack build` now
This commit is contained in:
2
examples/no_modules/.gitignore
vendored
2
examples/no_modules/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
no_modules.js
|
||||
no_modules_bg.wasm
|
@ -7,9 +7,7 @@
|
||||
You can build the example locally with:
|
||||
|
||||
```
|
||||
$ ./build.sh
|
||||
$ wasm-pack build --target no-modules
|
||||
```
|
||||
|
||||
(or running the commands on Windows manually)
|
||||
|
||||
and then opening `index.html` in a browser should run the example!
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
cargo build --target wasm32-unknown-unknown
|
||||
|
||||
cargo run --manifest-path ../../crates/cli/Cargo.toml \
|
||||
--bin wasm-bindgen -- \
|
||||
--no-modules \
|
||||
../../target/wasm32-unknown-unknown/debug/no_modules.wasm --out-dir .
|
||||
|
||||
python -m SimpleHTTPServer
|
@ -17,7 +17,7 @@
|
||||
</script>
|
||||
|
||||
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||
<script src='./no_modules.js'></script>
|
||||
<script src='./pkg/no_modules.js'></script>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', async () => {
|
||||
@ -26,7 +26,7 @@
|
||||
// here we tell bindgen the path to the wasm file so it can run
|
||||
// initialization and return to us a promise when it's done
|
||||
// also, we can use 'await' on the returned promise
|
||||
await wasm_bindgen('./no_modules_bg.wasm');
|
||||
await wasm_bindgen('./pkg/no_modules_bg.wasm');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user