From 85b780640aa5b4ca0538ce649a963cf2ae9be215 Mon Sep 17 00:00:00 2001 From: yokra9 <53964890+yokra9@users.noreply.github.com> Date: Sun, 21 Jun 2020 23:20:02 +0900 Subject: [PATCH 1/4] Fixed console_error_panic_hook was not working --- template/Cargo.toml | 15 ++++++++------- template/src/lib.rs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/template/Cargo.toml b/template/Cargo.toml index 71d764c..d113eaa 100644 --- a/template/Cargo.toml +++ b/template/Cargo.toml @@ -19,6 +19,8 @@ lto = true [features] # If you uncomment this line, it will enable `wee_alloc`: #default = ["wee_alloc"] +# If you uncomment this line, it will enable `console_error_panic_hook`: +#default = ["console_error_panic_hook"] [dependencies] # The `wasm-bindgen` crate provides the bare minimum functionality needed @@ -30,19 +32,18 @@ wasm-bindgen = "0.2.45" # allocator, so it's not enabled by default. wee_alloc = { version = "0.4.2", optional = true } +# The `console_error_panic_hook` crate provides better debugging of panics by +# logging them with `console.error`. This is great for development, but requires +# all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled +# in debug mode. +console_error_panic_hook = { version ="0.1.5", optional = true } + # The `web-sys` crate allows you to interact with the various browser APIs, # like the DOM. [dependencies.web-sys] version = "0.3.22" features = ["console"] -# The `console_error_panic_hook` crate provides better debugging of panics by -# logging them with `console.error`. This is great for development, but requires -# all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled -# in debug mode. -[target."cfg(debug_assertions)".dependencies] -console_error_panic_hook = "0.1.5" - # These crates are used for running unit tests. [dev-dependencies] wasm-bindgen-test = "0.2.45" diff --git a/template/src/lib.rs b/template/src/lib.rs index a649970..edca734 100644 --- a/template/src/lib.rs +++ b/template/src/lib.rs @@ -16,7 +16,7 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; pub fn main_js() -> Result<(), JsValue> { // This provides better error messages in debug mode. // It's disabled in release mode so it doesn't bloat up the file size. - #[cfg(debug_assertions)] + #[cfg(feature = "console_error_panic_hook")] console_error_panic_hook::set_once(); From 483a58524a88770039ab8413a5744146bd06049c Mon Sep 17 00:00:00 2001 From: yokra <53964890+yokra9@users.noreply.github.com> Date: Wed, 1 Sep 2021 22:28:00 +0900 Subject: [PATCH 2/4] Update template/Cargo.toml Co-authored-by: Herohtar --- template/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/Cargo.toml b/template/Cargo.toml index d113eaa..05637ec 100644 --- a/template/Cargo.toml +++ b/template/Cargo.toml @@ -34,8 +34,8 @@ wee_alloc = { version = "0.4.2", optional = true } # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires -# all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled -# in debug mode. +# all the `std::fmt` and `std::panicking` infrastructure, so it should only be +# enabled in debug mode. console_error_panic_hook = { version ="0.1.5", optional = true } # The `web-sys` crate allows you to interact with the various browser APIs, From 81ce97e6e685aaee0fc66b58d28291c56e016a54 Mon Sep 17 00:00:00 2001 From: yokra <53964890+yokra9@users.noreply.github.com> Date: Wed, 1 Sep 2021 22:28:34 +0900 Subject: [PATCH 3/4] Update template/src/lib.rs Co-authored-by: Herohtar --- template/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/src/lib.rs b/template/src/lib.rs index edca734..8b581ad 100644 --- a/template/src/lib.rs +++ b/template/src/lib.rs @@ -15,7 +15,7 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen(start)] pub fn main_js() -> Result<(), JsValue> { // This provides better error messages in debug mode. - // It's disabled in release mode so it doesn't bloat up the file size. + // It should be disabled in release mode so it doesn't bloat up the file size. #[cfg(feature = "console_error_panic_hook")] console_error_panic_hook::set_once(); From 8320dad4cdf4cbe805af20d762b4173da88b4c91 Mon Sep 17 00:00:00 2001 From: yokra9 <53964890+yokra9@users.noreply.github.com> Date: Wed, 1 Sep 2021 13:59:13 +0000 Subject: [PATCH 4/4] not redefine existing key 'features.default'. --- template/Cargo.toml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/template/Cargo.toml b/template/Cargo.toml index 05637ec..93b9c3d 100644 --- a/template/Cargo.toml +++ b/template/Cargo.toml @@ -17,10 +17,12 @@ crate-type = ["cdylib"] lto = true [features] -# If you uncomment this line, it will enable `wee_alloc`: -#default = ["wee_alloc"] -# If you uncomment this line, it will enable `console_error_panic_hook`: -#default = ["console_error_panic_hook"] +default = [ + # If you uncomment this line, it will enable `wee_alloc`: + # "wee_alloc", + # If you uncomment this line, it will enable `console_error_panic_hook`: + # "console_error_panic_hook" +] [dependencies] # The `wasm-bindgen` crate provides the bare minimum functionality needed