Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ crate-type = ["cdylib"]
lto = true

[features]
# If you uncomment this line, it will enable `wee_alloc`:
#default = ["wee_alloc"]
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
Expand All @@ -30,19 +34,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 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,
# 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"
Expand Down
4 changes: 2 additions & 2 deletions template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ 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.
#[cfg(debug_assertions)]
// 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();


Expand Down