Skip to content

Commit

Permalink
js: set console_error_panic_hook dep as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Jan 20, 2024
1 parent 55fce00 commit 4eb4919
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion webln-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion webln-js/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions webln-js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4eb4919

Please sign in to comment.