## Description This PR migrates the wasm example from an npm/webpack based approach to [trunk](https://trunkrs.dev/). Fixes #834. Of note: the `console_error_panic_hook` dependency was gated in `Cargo.toml` via `[target."cfg(debug_assertions)".dependencies]`. This is documented as nonfunctional and will throw a warning on build: ``` warning: Found `debug_assertions` in `target.'cfg(...)'.dependencies`. This value is not supported for selecting dependencies and will not work as expected. To learn more visit https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies ``` Since the actual usage of `console_error_panic_hook` is *also* gated in `lib.rs` behind `#[cfg(debug_assertions)]` it didn't make sense to have the cargo gate in place, hence I have removed it. ## Next steps If this PR is merged, the [wiki page](https://github.com/RustAudio/cpal/wiki/Setting-up-a-new-CPAL-WASM-project) linked in the root README should be updated as well.
40 lines
1.2 KiB
TOML
40 lines
1.2 KiB
TOML
[package]
|
|
name = "wasm-beep"
|
|
description = "cpal beep example for WebAssembly"
|
|
version = "0.1.0"
|
|
edition = "2018"
|
|
|
|
[lib]
|
|
crate-type = ["cdylib"]
|
|
|
|
[profile.release]
|
|
# This makes the compiled code faster and smaller, but it makes compiling slower,
|
|
# so it's only enabled in release mode.
|
|
lto = true
|
|
|
|
[features]
|
|
# If you uncomment this line, it will enable `wee_alloc`:
|
|
#default = ["wee_alloc"]
|
|
|
|
[dependencies]
|
|
cpal = { path = "../..", features = ["wasm-bindgen"] }
|
|
# `gloo` is a utility crate which improves ergonomics over direct `web-sys` usage.
|
|
gloo = "0.11.0"
|
|
# The `wasm-bindgen` crate provides the bare minimum functionality needed
|
|
# to interact with JavaScript.
|
|
wasm-bindgen = "0.2.45"
|
|
|
|
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
|
|
# compared to the default allocator's ~10K. However, it is slower than the default
|
|
# 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`.
|
|
console_error_panic_hook = "0.1.5"
|
|
|
|
# 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", "MouseEvent"]
|