From 4eb49193e9a057ed21f42dcd4f789e7cea580d37 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Sat, 20 Jan 2024 16:21:10 +0100 Subject: [PATCH] js: set `console_error_panic_hook` dep as optional --- webln-js/Cargo.toml | 5 ++++- webln-js/scripts/build.sh | 2 +- webln-js/src/lib.rs | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/webln-js/Cargo.toml b/webln-js/Cargo.toml index 99934d7..0dde2c4 100644 --- a/webln-js/Cargo.toml +++ b/webln-js/Cargo.toml @@ -13,8 +13,11 @@ keywords = ["webln", "lightning", "bitcoin", "javascript"] [lib] crate-type = ["lib", "cdylib"] +[features] +default = [] + [dependencies] -console_error_panic_hook = "0.1" +console_error_panic_hook = { version = "0.1", optional = true } js-sys.workspace = true webln = { version = "0.1", path = "../webln", default-features = false } wasm-bindgen.workspace = true diff --git a/webln-js/scripts/build.sh b/webln-js/scripts/build.sh index 9bd2541..f41088f 100755 --- a/webln-js/scripts/build.sh +++ b/webln-js/scripts/build.sh @@ -16,7 +16,7 @@ set -e cd $(dirname "$0")/.. -wasm-pack build --target nodejs --no-pack --scope shadowylab --weak-refs --out-dir pkg "${WASM_PACK_ARGS[@]}" +wasm-pack build --target nodejs --no-pack --scope shadowylab --weak-refs --out-dir pkg "${WASM_PACK_ARGS[@]}" --features "console_error_panic_hook" # Shrinking .wasm Size wc -c pkg/webln_js_bg.wasm diff --git a/webln-js/src/lib.rs b/webln-js/src/lib.rs index 8041464..329938b 100644 --- a/webln-js/src/lib.rs +++ b/webln-js/src/lib.rs @@ -30,6 +30,7 @@ use self::request_invoice::{JsRequestInvoiceArgs, JsRequestInvoiceResponse}; use self::send_payment::JsSendPaymentResponse; use self::sign_message::JsSignMessageResponse; +#[cfg(feature = "console_error_panic_hook")] #[wasm_bindgen(start)] pub fn start() { console_error_panic_hook::set_once();