From 40d07122bad028923fee6a64492950102310e4fa Mon Sep 17 00:00:00 2001 From: funman300 Date: Tue, 12 May 2026 14:00:13 -0700 Subject: [PATCH] docs(wasm): add build_wasm.sh to document wasm-pack invocation Captures the exact wasm-pack build command needed to regenerate solitaire_server/web/pkg/. Removes wasm-pack's package.json and .gitignore artifacts from the output dir since we manage it directly. Includes a dependency guard and install instructions. Co-Authored-By: Claude Sonnet 4.6 --- build_wasm.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 build_wasm.sh diff --git a/build_wasm.sh b/build_wasm.sh new file mode 100755 index 0000000..c826544 --- /dev/null +++ b/build_wasm.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Rebuild the solitaire_wasm crate and install the output into +# solitaire_server/web/pkg/ so the server can serve the replay viewer. +# +# Prerequisites: +# cargo install wasm-pack +# rustup target add wasm32-unknown-unknown +# +# Run from the repo root: +# ./build_wasm.sh +# +# The generated files (solitaire_wasm.js + solitaire_wasm_bg.wasm) are +# committed to git so self-hosters who don't touch the WASM crate can +# skip this step. Regenerate after any change to solitaire_wasm/ or +# solitaire_core/. + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +OUT_DIR="$REPO_ROOT/solitaire_server/web/pkg" + +if ! command -v wasm-pack &> /dev/null; then + echo "error: wasm-pack not found." >&2 + echo " Install with: cargo install wasm-pack" >&2 + exit 1 +fi + +echo "Building solitaire_wasm (target: web)..." +wasm-pack build \ + --target web \ + --out-dir "$OUT_DIR" \ + --no-typescript \ + "$REPO_ROOT/solitaire_wasm" + +# wasm-pack writes a package.json and .gitignore into the output dir. +# Remove them — we manage the output directory ourselves. +rm -f "$OUT_DIR/package.json" "$OUT_DIR/.gitignore" + +echo "Done. Output:" +ls -lh "$OUT_DIR"