From 9b195aeb0347fa5d97aab31291109f64050148e9 Mon Sep 17 00:00:00 2001 From: Orual Date: Fri, 26 Jun 2026 23:32:50 -0400 Subject: [PATCH] build: optimize web release profile + wasm-opt pass --- Cargo.toml | 3 +++ justfile | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 26427f2..5077e44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,6 +171,9 @@ serde_json = "1.0" [profile.web-release] inherits = "release" opt-level = "z" +debug = false lto = "fat" codegen-units = 1 strip = "symbols" +panic = "abort" +incremental = false diff --git a/justfile b/justfile index 779d8a3..2a9326f 100644 --- a/justfile +++ b/justfile @@ -53,9 +53,26 @@ e2e: # Start the Dioxus dev server. serve *ARGS: dx serve {{ ARGS }} -# Build the Dioxus app for web. +# Build the Dioxus app for web (debug). build-web: dx build --platform web +# Build the Dioxus app for web (release, optimized). Strips debug symbols and runs wasm-opt. +build-web-release: + #!/usr/bin/env bash + set -e + dx build --platform web --release --debug-symbols=false + if command -v wasm-opt &>/dev/null; then + WASM=$(find target/dx/polymodel/release/web/public -name "polymodel_bg*.wasm" -print -quit 2>/dev/null) + if [ -n "$WASM" ]; then + echo "==> Running wasm-opt on $WASM" + BEFORE=$(stat -c%s "$WASM") + wasm-opt "$WASM" -Oz --enable-bulk-memory --enable-simd --enable-nontrapping-float-to-int --enable-sign-ext -o "$WASM" || { echo "==> wasm-opt failed, keeping unoptimized wasm"; exit 0; } + AFTER=$(stat -c%s "$WASM") + echo " $BEFORE -> $AFTER bytes" + fi + else + echo "==> wasm-opt not found, skipping optimization" + fi # Regenerate crates/polymodel-api from authored lexicons via the local Jacquard checkout. generate-api: nix run ../jacquard -- 2.51.2