diff --git a/web/assemble.sh b/web/assemble.sh index 1fe1cd20..a1492d1e 100755 --- a/web/assemble.sh +++ b/web/assemble.sh @@ -73,18 +73,31 @@ sedi "s|'improvise_worker_server_bg\.wasm'|'improvise_worker_server_bg.wasm?v=${ # three failed substitutions could still produce a "successful" assembly under # `set -e` (found by Copilot on PR #24). These checks are the only guard # against the generated glue changing shape, so each stamped reference is -# verified on its own and names itself when it is the one missing. +# verified on its own and names itself when it is missing. +# +# `stamped` RECORDS rather than exits, and the gate below is what fails the +# build. Exiting on the first failure named one file and never reached the +# rest, so a shape change that broke two stamps cost two wasm-pack rebuilds to +# diagnose -- the slowest loop in this repo (improvise-x4wv). The gate is the +# whole guard: without it every failure prints and the assembly succeeds, which +# is the check-that-does-not-check this whole file is full of fixes for. +missing="" stamped() { - grep -q "$2" "$1" || { + if grep -q "$2" "$1"; then + grep -n "$2" "$1" + else echo "assemble: $1 is missing the cache-bust stamp: $2" >&2 - exit 1 - } - grep -n "$2" "$1" + missing="${missing} $1" + fi } stamped "$app/app.js" "pkg/improvise_wasm_client.js?v=${token}" stamped "$app/worker.js" "worker-pkg/improvise_worker_server.js?v=${token}" stamped "$app/pkg/improvise_wasm_client.js" "improvise_wasm_client_bg.wasm?v=${token}" stamped "$app/worker-pkg/improvise_worker_server.js" "improvise_worker_server_bg.wasm?v=${token}" +test -z "$missing" || { + echo "assemble: refusing to ship; unstamped:${missing}" >&2 + exit 1 +} # Every relative import the two entry points make must have been copied. The # cp list above is a second answer to "what ships", and a missing sibling is a