File size: 1,097 Bytes
9425aed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/bin/bash
#
# Build Sovereign WASM Operations
# Compiles Rust source to WASM using wasm-pack
#
# Output: ../dist/ directory with bundler-compatible WASM
# Binary size target: <500KB (release)
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Building Sovereign WASM Operations..."
echo "Target: wasm32-unknown-unknown (bundler-compatible)"
echo ""
# Build with wasm-pack
# --target bundler: Generates ES module format for bundlers (webpack, vite, etc.)
# --release: Optimized build with LTO and size optimization
# --out-dir: Output directory relative to Cargo.toml location
wasm-pack build \
--target bundler \
--release \
--out-dir dist/
echo ""
echo "Build complete!"
echo ""
# Report binary sizes
if [ -f "dist/sovereign_wasm_ops.wasm" ]; then
SIZE=$(ls -lh dist/sovereign_wasm_ops.wasm | awk '{print $5}')
echo "WASM binary size: $SIZE"
fi
# List all generated files
echo ""
echo "Generated files in dist/:"
ls -lh dist/ | grep -v "^total" | awk '{printf " %-40s %8s\n", $9, $5}'
echo ""
echo "✓ Ready for production"
|