Skip to content

Commit 796cc42

Browse files
authored
Switch to wasm-opt cli (#303)
# Objective Currently, we use `wasm-opt` as a library to optimize the wasm binaries. This makes our compile times noticeably longer. To reduce compile and therefore CI time we switch to use the `wasm-opt` CLI variant. # Solution 1. Move the `wasm-opt` module to `external_cli` 2. Remove `wasm-opt` from the dependencies 3. Add `wasm-opt`to the `ensure_web_setup` function that installs the latest available version if no version is present and the user confirms. # Testing No wasm opt ```sh ❯ cargo install --path . ❯ bevy run -r web -v DEBUG Running: `rustup target list` DEBUG Running: `wasm-bindgen --version` INFO Compiling to WebAssembly... DEBUG Running: `cargo build --config profile.web.inherits="dev" --config profile.web-release.inherits="release" --config profile.web-release.strip="debuginfo" --config profile.web-release.opt-level="s" --bin cplx --profile web-release --target wasm32-unknown-unknown` Finished `web-release` profile [optimized] target(s) in 0.11s INFO Bundling JavaScript bindings... DEBUG Running: `wasm-bindgen --no-typescript --out-name cplx --out-dir /bevy_complex_repo/app/target/wasm32-unknown-unknown/web-release --target web /bevy_complex_repo/app/target/wasm32-unknown-unknown/web-release/cplx.wasm` INFO No custom `web` folder found, using defaults. INFO Open your app at <http://localhost:4000>! ``` With `wasm-opt` ``` ❯ cargo install --path . --features wasm-opt ❯ bevy run -r web -v DEBUG Running: `rustup target list` DEBUG Running: `wasm-bindgen --version` DEBUG Running: `wasm-opt --version` INFO Compiling to WebAssembly... DEBUG Running: `cargo build --config profile.web.inherits="dev" --config profile.web-release.inherits="release" --config profile.web-release.opt-level="s" --config profile.web-release.strip="debuginfo" --bin cplx --profile web-release --target wasm32-unknown-unknown` Finished `web-release` profile [optimized] target(s) in 0.10s INFO Bundling JavaScript bindings... DEBUG Running: `wasm-bindgen --no-typescript --out-name cplx --out-dir /bevy_complex_repo/app/target/wasm32-unknown-unknown/web-release --target web /bevy_complex_repo/app/target/wasm32-unknown-unknown/web-release/cplx.wasm` INFO Optimizing with wasm-opt... DEBUG Running: `wasm-opt --strip-debug -Oz -o /bevy_complex_repo/app/target/wasm32-unknown-unknown/web-release/cplx_bg.wasm /bevy_complex_repo/app/target/wasm32-unknown-unknown/web-release/cplx_bg.wasm` INFO Finished in 18.36s. Size reduced by 48%. INFO No custom `web` folder found, using defaults. INFO Open your app at <http://localhost:4000>! ``` Closes #289
1 parent bd4e364 commit 796cc42

File tree

6 files changed

+124
-292
lines changed

6 files changed

+124
-292
lines changed

0 commit comments

Comments
 (0)