forked from external-repos/squoosh
wasm-pack auto-downloads and runs a fixed version of wasm-opt, but wasm-pack itself hasn't been maintained for a while, and so wasm-opt that comes with it is also severely outdated, leading to all sorts of hidden issues (compiler errors, broken atomics code, etc.) as well as missed optimisations. This change disable wasm-opt feature of wasm-pack in all Rust codecs and runs the latest wasm-opt manually instead.
16 lines
716 B
Bash
Executable File
16 lines
716 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
rm -rf pkg,{-parallel}
|
|
export CFLAGS="${CFLAGS} -DUNALIGNED_ACCESS_IS_FAST=1"
|
|
wasm-pack build -t web -- --locked
|
|
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' wasm-pack build -t web -d pkg-parallel -- -Z build-std=panic_abort,std --features=parallel --locked
|
|
# Workaround https://github.com/rustwasm/wasm-bindgen/issues/2133:
|
|
sed -i "s|maybe_memory:|maybe_memory?:|" pkg-parallel/squoosh_oxipng.d.ts
|
|
# Workaround wasm-pack using a very old wasm-opt.
|
|
echo "Optimizing wasm binaries with \`wasm-opt\`..."
|
|
wasm-opt -O pkg/squoosh_oxipng_bg.wasm -o pkg/squoosh_oxipng_bg.wasm
|
|
wasm-opt -O pkg-parallel/squoosh_oxipng_bg.wasm -o pkg-parallel/squoosh_oxipng_bg.wasm
|
|
rm pkg{,-parallel}/.gitignore
|