From eaf8a1e57fb1c9641ca095d9b7d2520768d21159 Mon Sep 17 00:00:00 2001 From: Anthony Dodd Date: Fri, 6 Aug 2021 10:39:18 -0500 Subject: [PATCH] Only use wasm-opt when in release mode This addresses a few pain points where there was no way to reasonably disable wasm-opt use for debug builds while keeping it enabled for release builds. There seems to be very few (if any) use cases for using wasm-opt on a debug build, as such, wasm-opt is now only run on release builds when enabled. closes #197 closes #175 --- CHANGELOG.md | 1 + examples/vanilla/index.html | 2 +- examples/yew/index.html | 2 +- site/content/assets.md | 4 ++-- src/pipelines/rust_app.rs | 5 +++++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 092e3c89..34f3232d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe - Fixed [#209](https://github.com/thedodd/trunk/issues/209) where the default Rust App pipeline was causing wasm-opt to be used even for debug builds when the Rust App HTML link was being omitted. - Closed [#168](https://github.com/thedodd/trunk/issues/158): RSS feed for blog. - Isolated code used for version checking & formatting of version output for downloadable applications (wasm-bindgen & wasm-opt). Added unit tests to cover this logic. +- Fixed [#197](https://github.com/thedodd/trunk/issues/197) & [#175](https://github.com/thedodd/trunk/pull/175) where disabling wasm-opt for debug builds while keeping it enable for release builds was not possible without some hacking. Now, wasm-opt will only be used for release builds and only when enabled. This semantically matches cargo's behavior with optimizations in release mode. ## 0.12.1 ### fixed diff --git a/examples/vanilla/index.html b/examples/vanilla/index.html index 65001600..e33f712f 100644 --- a/examples/vanilla/index.html +++ b/examples/vanilla/index.html @@ -10,6 +10,6 @@ - + diff --git a/examples/yew/index.html b/examples/yew/index.html index 65a75ba3..95464b14 100644 --- a/examples/yew/index.html +++ b/examples/yew/index.html @@ -14,6 +14,6 @@ - + diff --git a/site/content/assets.md b/site/content/assets.md index 32939dfa..44c83e69 100644 --- a/site/content/assets.md +++ b/site/content/assets.md @@ -17,8 +17,8 @@ This will typically look like: ` Result<()> { + // If not in release mode, we skip calling wasm-opt. + if !self.cfg.release { + return Ok(()); + } + // If opt level is off, we skip calling wasm-opt as it wouldn't have any effect. if self.wasm_opt == WasmOptLevel::Off { return Ok(());