Skip to content

Upgrading wasm-bindgen 0.1 to 0.2

Breaking0.1.0 โ†’ 0.2.130Breaking13Platform4New146Changed79Fixed154

Fetching 129 releases from GitHubโ€ฆ35 / 129
BreakingUpgrade verdict

13 breaking changes and 4 platform requirement changes.

  • Two unstable method names changed, so code calling the old names must be updated.
  • Some previously accepted slice_to_array uses now fail to compile, and some values are no longer copied needlessly.
  • JsOption now only considers undefined to mean no value; null is treated as a real value. Code that expected null to become None must change.
  • Removed ImmediateClosure type introduced in 0.2.109.
Top 5 of 17 that need code or config changes

Requires Rust 1.81 from 0.2.129 (none stated before).

Adds cfg-if ^1.0.0, paste ^1, rustversion ^1.0.6, serde ^1.0, serde_derive ^1.0, serde_json ^1.0, tokio ^1, wasm-bindgen-shared =0.2.130.

Installs 20 packages in all (was 17).

Also installs bumpalo, pin-project-lite, wasm-bindgen-macro-support.

No longer installs fnv, unicode-xid.

Moves proc-macro2 0.2.3, 1.0.107 โ†’ 1.0.107, quote 0.4.2, 1.0.47 โ†’ 1.0.47, syn 0.12.15, 2.0.56 โ†’ 2.0.56, 3.0.9, wasm-bindgen-macro 0.1.1 โ†’ 0.2.130, wasm-bindgen-shared 0.1.1 โ†’ 0.2.130. Your build may pick other versions.

Breaking13
Renames unstable overload APIs to elide shared name tokens: LockManager::request_with_callback becomes request and request_with_options_and_callback becomes request_with_options.
LockManager::request_with_callbackLockManager::requestLockManager::request_with_options_and_callbackLockManager::request_with_options
Makes slice_to_array on &mut slices or generic element types a compile error and removes a redundant copy for strings and arrays received by JS.
slice_to_arrayVec<String>
JsOption<T> now treats only undefined as empty, making JS null a distinct present value and removing the UpcastFrom<Null> impl.
JsOptionis_emptyas_optioninto_optionunwrapexpectunwrap_or_defaultunwrap_or_else
Removed ImmediateClosure type introduced in 0.2.109.
ImmediateClosureScopedClosure::immediate
Setting js_namespace on both an extern "C" block and an item inside it is now a hard error; nested paths must use a single attribute.
js_namespaceextern "C"
Changes WebGPU setImmediates APIs to take an immutable u8 slice.
setImmediates
Changes Web Bluetooth writeValue variants and WebUSB controlTransferOut, transferOut and isochronousTransferOut APIs to take immutable u8 slices.
writeValuewriteValueWithResponsewriteValueWithoutResponsecontrolTransferOuttransferOutisochronousTransferOut
Fixes incorrect variance in &mut reference upcasting by making mutable references invariant in their pointee.
UpcastFrom
Exported structs using js_namespace now require the namespace to be repeated on every impl block.
js_namespacewasm_bindgen
Internal crate wasm-bindgen-backend will no longer be published.
wasm-bindgen-backend
Crates intended purely for internal consumption by the wasm-bindgen CLI will no longer be published.
wasm-bindgen-externref-xformwasm-bindgen-multi-value-xformwasm-bindgen-threads-xformwasm-bindgen-wasm-conventionswasm-bindgen-wasm-interpreter
Removed Gecko-only InstallTriggerData and Gecko-internal FlexLineGrowthState, GridDeclaration, GridTrackState, RtcLifecycleEvent and WebrtcGlobalStatisticsReport features.
InstallTriggerDataFlexLineGrowthStateGridDeclarationGridTrackStateRtcLifecycleEventWebrtcGlobalStatisticsReport
Removed Gecko-internal dictionary bindings Csp, CspPolicies, CspReport and CspReportProperties.
CspCspPoliciesCspReportCspReportProperties
Platform4
Bumps the library MSRV from 1.77 to 1.81, per the 2-year MSRV policy.
-Cpanic=unwind on wasm now emits modern exnref exception handling by default and requires Node.js 22.22.3+.
WebAssembly.JSTag-Cpanic=unwind-Cllvm-args=-wasm-use-legacy-eh
MSRV bump from 1.71 to 1.76 for the CLI, and 1.82 to 1.86 for the API.
New MSRV policy, and bump of the MSRV fo 1.71.