2018-04-20 21:13:28 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2018-04-23 11:32:57 -05:00
|
|
|
# This is the same build.sh, later we are going to use the
|
|
|
|
# fetch flag to avoid including the wasm module as a string
|
|
|
|
# of base64, instead using the js `fetch` function
|
|
|
|
#to request the module from the server.
|
2018-04-20 21:13:28 -05:00
|
|
|
cargo +nightly build --target wasm32-unknown-unknown
|
|
|
|
cargo +nightly run -p wasm-bindgen-cli --bin wasm-bindgen -- \
|
|
|
|
../../../target/wasm32-unknown-unknown/debug/hello_world.wasm --out-dir .
|
|
|
|
|
|
|
|
# To avoid a bug occurring when webpack, wasm, and Chrome are used together, we
|
2018-04-23 09:04:30 -05:00
|
|
|
# create a .js module that will download the .wasm module via fetch.
|
2018-04-20 21:13:28 -05:00
|
|
|
cargo +nightly run -p wasm-bindgen-cli --bin wasm2es6js -- \
|
2018-04-23 09:04:30 -05:00
|
|
|
--fetch ./hello_world_bg.wasm -o hello_world_bg.js hello_world_bg.wasm
|
2018-04-20 21:13:28 -05:00
|
|
|
|
2018-04-23 11:32:57 -05:00
|
|
|
# Install the npm items as usual.
|
2018-04-20 21:13:28 -05:00
|
|
|
npm install
|
2018-04-23 09:04:30 -05:00
|
|
|
|
|
|
|
# since we kept the same name for the .js module, we need
|
|
|
|
# to force webpack to ignore any other file extensions
|
2018-04-20 21:13:28 -05:00
|
|
|
npm run serve -- --resolve-extensions .js
|