From a0807cb337a19bef0ca7aba9054fd363880db687 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:51:37 +0000 Subject: [PATCH] crypto-js: support `npm run build:dev` (#1510) Building the crypto-js bindings in release mode is very slow and not really necessary for local development. `--release` is the default, so there is no need to specify it explicitly. Instead, allow `wasm-pack` args to be specified by an env var, and add a `build:debug` npm script which will build in debug mode. --- bindings/matrix-sdk-crypto-js/package.json | 3 ++- bindings/matrix-sdk-crypto-js/scripts/build.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bindings/matrix-sdk-crypto-js/package.json b/bindings/matrix-sdk-crypto-js/package.json index b5724c0bc..47c5bb57c 100644 --- a/bindings/matrix-sdk-crypto-js/package.json +++ b/bindings/matrix-sdk-crypto-js/package.json @@ -40,7 +40,8 @@ }, "scripts": { "lint": "prettier --check .", - "build": "./scripts/build.sh", + "build": "WASM_PACK_ARGS=--release ./scripts/build.sh", + "build:dev": "WASM_PACK_ARGS=--dev ./scripts/build.sh", "test": "jest --verbose", "doc": "typedoc --tsconfig .", "prepack": "npm run build && npm run test" diff --git a/bindings/matrix-sdk-crypto-js/scripts/build.sh b/bindings/matrix-sdk-crypto-js/scripts/build.sh index 6eb149a96..f782a2b2e 100755 --- a/bindings/matrix-sdk-crypto-js/scripts/build.sh +++ b/bindings/matrix-sdk-crypto-js/scripts/build.sh @@ -16,7 +16,7 @@ set -e cd $(dirname "$0")/.. -RUSTFLAGS='-C opt-level=z' WASM_BINDGEN_WEAKREF=1 wasm-pack build --release --target nodejs --scope matrix-org --out-dir pkg +RUSTFLAGS='-C opt-level=z' WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs --scope matrix-org --out-dir pkg "${WASM_PACK_ARGS[@]}" # Convert the Wasm into a JS file that exports the base64'ed Wasm. echo "module.exports = \`$(base64 pkg/matrix_sdk_crypto_js_bg.wasm)\`;" > pkg/matrix_sdk_crypto_js_bg.wasm.js