mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 15:59:20 +03:00
32 lines
923 B
Bash
Executable File
32 lines
923 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eux
|
|
|
|
if [[ ! -d repl_www ]]
|
|
then
|
|
echo "This script should be run from the project root"
|
|
exit 1
|
|
fi
|
|
|
|
if ! which wasm-pack
|
|
then
|
|
cargo install wasm-pack
|
|
fi
|
|
|
|
WWW_DIR="repl_www/build"
|
|
mkdir -p $WWW_DIR
|
|
cp repl_www/public/* $WWW_DIR
|
|
|
|
# Pass all script arguments through to wasm-pack
|
|
# For debugging, pass the --profiling option, which enables optimizations + debug info
|
|
# (We need optimizations to get rid of dead code that otherwise causes compile errors!)
|
|
wasm-pack build --target web "$@" repl_wasm
|
|
|
|
cp repl_wasm/pkg/*.wasm $WWW_DIR
|
|
|
|
# Copy the JS from wasm_bindgen, replacing its invalid `import` statement with a `var`.
|
|
# The JS import from the invalid path 'env', seems to be generated when there are unresolved symbols.
|
|
BINDGEN_FILE="roc_repl_wasm.js"
|
|
echo 'var __wbg_star0 = { now: Date.now };' > $WWW_DIR/$BINDGEN_FILE
|
|
grep -v '^import' repl_wasm/pkg/$BINDGEN_FILE >> $WWW_DIR/$BINDGEN_FILE
|