Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Rust Wasm Module Size By 85% (wasm-snip) #898

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ RUN curl -L https://github.com/WebAssembly/binaryen/releases/download/version_10
# Install the toml-cli
RUN cargo install toml-cli

# Install wasm-snip
RUN cargo install wasm-snip

{{#web3api_linked_packages.length}}
WORKDIR /linked-packages
{{/web3api_linked_packages.length}}
Expand Down Expand Up @@ -105,5 +108,7 @@ RUN mkdir ./build
# Use wasm-opt to perform the "asyncify" post-processing step over all modules
{{#web3api_modules}}
RUN WASM_MODULE=$(ls ./{{dir}}/target/wasm32-unknown-unknown/release/*.wasm); \
wasm-opt --asyncify -O2 $WASM_MODULE -o ./build/{{name}}.wasm
wasm-snip $WASM_MODULE -o ./build/snipped_{{name}}.wasm && \
wasm-opt --asyncify -Os ./build/snipped_{{name}}.wasm -o ./build/{{name}}.wasm && \
rm -rf ./build/snipped_{{name}}.wasm
{{/web3api_modules}}