Skip to main content

optimize_wasm

Function optimize_wasm 

Source
pub async fn optimize_wasm(wasm_path: &Path, opt_level: &str) -> Result<PathBuf>
Expand description

Optimize a WASM binary using wasm-opt.

Falls back gracefully if wasm-opt is not installed, logging a warning.

§Arguments

  • wasm_path - Path to the WASM binary to optimize
  • opt_level - Optimization level: “O”, “Os”, “Oz”, “O2”, “O3”

§Returns

Path to the optimized binary (.opt.wasm extension)

§Errors

Returns an error if wasm-opt is found but fails to run successfully.