diff --git a/.gitignore b/.gitignore index 4e6d578..42680c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target /html/opentally.js -/html/opentally_bg.wasm +/html/opentally_*.wasm diff --git a/build_wasm.sh b/build_wasm.sh index 0b43028..e569d50 100755 --- a/build_wasm.sh +++ b/build_wasm.sh @@ -1,3 +1,19 @@ #!/bin/sh +PATH=$PATH:$HOME/.cargo/bin + +# Build cargo PROFILE=${1:-release} -cargo build --lib --target wasm32-unknown-unknown --$PROFILE && /home/runassudo/.cargo/bin/wasm-bindgen --target no-modules target/wasm32-unknown-unknown/$PROFILE/opentally.wasm --out-dir html --no-typescript +if [ $PROFILE == 'debug' ]; then + cargo build --lib --target wasm32-unknown-unknown +else + cargo build --lib --target wasm32-unknown-unknown --$PROFILE +fi + +# Apply wasm-bindgen +wasm-bindgen --target no-modules target/wasm32-unknown-unknown/$PROFILE/opentally.wasm --out-dir html --no-typescript + +# Apply Asyncify +MANGLED=$(wasm-dis html/opentally_bg.wasm | grep '(import "wbg" "__wbg_getuserinput_' | awk '{print $3;}' | tr -d '"') +wasm-opt -O2 --asyncify --pass-arg asyncify-imports@wbg.$MANGLED html/opentally_bg.wasm -o html/opentally_async.wasm + +rm html/opentally_bg.wasm diff --git a/html/index.html b/html/index.html index d4519c2..eb7c822 100644 --- a/html/index.html +++ b/html/index.html @@ -295,7 +295,6 @@