diff --git a/Cargo.toml b/Cargo.toml index 888c739..77ac230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ tracing = { version = "0.1.37", optional = true } tracing-opentelemetry = { version = "0.20.0", optional = true } tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] } walkdir = { version = "2.3.3", optional = true } +wasm-bindgen = { version = "0.2.89", optional = true } [build-dependencies] walkdir = "2.3.3" @@ -66,7 +67,7 @@ compare = ["tokio/process", "tokio/macros"] foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir", "tokio/process"] tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"] event_count = [] -wasm = ["dep:serde"] +wasm = ["dep:serde", "dep:wasm-bindgen"] # Optimized build for any sort of release. [profile.release-lto] diff --git a/src/bin_wasm.rs b/src/bin_wasm.rs index 2496df2..e5a9427 100644 --- a/src/bin_wasm.rs +++ b/src/bin_wasm.rs @@ -1,6 +1,7 @@ #![no_main] +use wasm_bindgen::prelude::wasm_bindgen; -#[no_mangle] -pub extern "C" fn add(left: usize, right: usize) -> usize { +#[wasm_bindgen] +pub fn add(left: usize, right: usize) -> usize { left + right }