Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Run a lighter pass for non production builds
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Sep 21, 2022
1 parent f33171b commit 997c046
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,15 @@ fn compact_wasm_file(
.join(format!("{}.wasm", default_out_name));

let (wasm_compact_path, wasm_compact_compressed_path) = if profile.wants_compact() {
// Only in production we want to spend substantial time on optimizing. Otherwise we just
// run level 1 which bare takes a second.
let mut optimizer = match profile {
Profile::Production =>
wasm_opt::OptimizationOptions::new_optimize_for_size_aggressively(),
_ => wasm_opt::OptimizationOptions::new_opt_level_1(),
};
let wasm_compact_path = project.join(format!("{}.compact.wasm", out_name,));
wasm_opt::OptimizationOptions::new_optimize_for_size_aggressively()
optimizer
.zero_filled_memory(true)
.run(&in_path, Option::<&str>::None, &wasm_compact_path, Option::<&str>::None)
.expect("Failed to compact generated WASM binary.");
Expand Down

0 comments on commit 997c046

Please sign in to comment.