Files
photoreport/infra/engine/build-wasm.sh
spark adb557290c
ci / rust (push) Successful in 7m1s
ci / typescript (push) Successful in 7m36s
Release hardening: no symbols, no source maps, no wasm names
Rust release profiles strip symbols and debug info (desktop: fat LTO, panic=abort), the web app and site ship
without source maps, and wasm-opt drops debug, producer and name sections from the engine.

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-12 16:13:37 +01:00

17 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the browser engine (engine/wasm) into apps/app/public/engine/, where the editor's worker loads it.
# Needs: rustup target add wasm32-unknown-unknown; cargo install wasm-bindgen-cli --version 0.2.129 --locked
# (the CLI version must match the wasm-bindgen crate pinned in engine/wasm/Cargo.toml).
set -Eeuo pipefail
cd "$(dirname "$0")/../.."
OUT="apps/app/public/engine"
want="$(sed -n 's/^wasm-bindgen = "=\(.*\)"/\1/p' engine/wasm/Cargo.toml)"
have="$(wasm-bindgen --version 2>/dev/null | awk '{print $2}')"
[[ "$have" == "$want" ]] || { echo "wasm-bindgen CLI $want needed (found: ${have:-none}): cargo install wasm-bindgen-cli --version $want --locked" >&2; exit 1; }
cargo build --locked --profile wasm --target wasm32-unknown-unknown -p photoreport-engine-wasm
rm -rf "$OUT"
wasm-bindgen --target web --no-typescript --out-dir "$OUT" target/wasm32-unknown-unknown/wasm/photoreport_engine_wasm.wasm
# wasm-opt also drops the function-name section (no -g), so the module carries no internal names.
if command -v wasm-opt >/dev/null 2>&1; then wasm-opt -O3 --strip-debug --strip-producers --enable-bulk-memory --enable-nontrapping-float-to-int -o "$OUT/photoreport_engine_wasm_bg.wasm" "$OUT/photoreport_engine_wasm_bg.wasm"; fi
ls -l "$OUT"