Skip to content

Commit 6008e90

Browse files
authored
Fix WASM MVP (#168)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective After we compile the MVP WASM build for wasm2js, we need to run wasm-bindgen to do it's thing, otherwise the build completes but it's not useable in webpack. As wasm-bindgen generates a whole folder with duplicate support scripts, I've pointed it to a temp folder that is then deleted at the end. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent b091af6 commit 6008e90

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/bitwarden-wasm-internal/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ wasm-bindgen --target nodejs --out-dir crates/bitwarden-wasm-internal/npm/node .
2929
# this normally requires a nightly build, but we can also use the
3030
# RUSTC_BOOTSTRAP hack to use the same stable version as the normal build
3131
RUSTFLAGS=-Ctarget-cpu=mvp RUSTC_BOOTSTRAP=1 cargo build -p bitwarden-wasm-internal -Zbuild-std=panic_abort,std --target wasm32-unknown-unknown ${RELEASE_FLAG}
32-
cp ./target/wasm32-unknown-unknown/${BUILD_FOLDER}/bitwarden_wasm_internal.wasm ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.mvp.wasm
32+
wasm-bindgen --target bundler --out-dir crates/bitwarden-wasm-internal/npm/mvp ./target/wasm32-unknown-unknown/${BUILD_FOLDER}/bitwarden_wasm_internal.wasm
3333

3434
# Format
3535
npx prettier --write ./crates/bitwarden-wasm-internal/npm
3636

3737
# Optimize size
3838
wasm-opt -Os ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.wasm -o ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.wasm
3939
wasm-opt -Os ./crates/bitwarden-wasm-internal/npm/node/bitwarden_wasm_internal_bg.wasm -o ./crates/bitwarden-wasm-internal/npm/node/bitwarden_wasm_internal_bg.wasm
40-
wasm-opt -Os ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.mvp.wasm -o ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.mvp.wasm
40+
wasm-opt -Os crates/bitwarden-wasm-internal/npm/mvp/bitwarden_wasm_internal_bg.wasm -o ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.mvp.wasm
4141

4242
# Transpile to JS
4343
wasm2js ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.mvp.wasm -o ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.wasm.js
4444
npx terser ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.wasm.js -o ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.wasm.js
4545

4646
# Remove unneeded files
47-
rm ./crates/bitwarden-wasm-internal/npm/bitwarden_wasm_internal_bg.mvp.wasm
47+
rm -rf ./crates/bitwarden-wasm-internal/npm/mvp

0 commit comments

Comments
 (0)