-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: avoid full wasm optimizations in development (#6656)
The `-O3` level optimization for wingc's wasm is pretty slow but worth keeping in for the final build. For local dev it's still valuable to run wasm-opt with some optimization as it greatly reduces the size of the wasm file, which then improves performance when JS loads it. The base level optimization runs in like 500ms on my machine so it's not much of a problem. *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
- Loading branch information
1 parent
cdfab81
commit 4aed089
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
### | ||
# This script should be run after release build of wingc to the wasm32-wasi target. | ||
# The end result will be a final wasm file in the wingc directory. | ||
# If running in CI (env "CI" is set), it will run wasm-opt on the generated wasm file. | ||
# Otherwise, the wasm file will be copied to the wingc directory from its original output location. | ||
### | ||
|
||
wingc=$(cd $(dirname $0)/.. && pwd) | ||
|
||
# Currently we only do release wasm builds | ||
target="release" | ||
|
||
wasm_opt="$wingc/../../.cargo/binaryen-version_117/bin/wasm-opt" | ||
input_wasm="$wingc/../../target/wasm32-wasi/$target/wingc.wasm" | ||
output_wasm="$wingc/wingc.wasm" | ||
|
||
# If CI env is set, run wasm-opt with extra optimizations | ||
echo "Optimising wasm..." | ||
if [ -n "$CI" ]; then | ||
$wasm_opt --enable-bulk-memory --strip-debug --strip-producers -O3 -o $output_wasm $input_wasm | ||
else | ||
$wasm_opt --enable-bulk-memory --strip-debug --strip-producers -o $output_wasm $input_wasm | ||
fi | ||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters