Avatar for the wasm-bindgen user
wasm-bindgen
wasm-bindgen
BlogDocsChangelog

Performance History

Latest Results

Fix invalid TS emission for namespaced (js_namespace) emscripten exports The emscripten .d.ts emission produced three TS-invalid forms for namespaced struct/impl, enum, and free-function exports: 1. The mangled identifier (e.g. app__math__Calc) leaked publicly because the class/enum/function were emitted as `export class` and the file was script-scoped (so even `declare class` would have leaked as a global). Consumers could write `const c: app__math__Calc = ...` and pin to an internal implementation detail. 2. An unqualified `Calc: typeof app__math__Calc` property was added to `interface BindgenModule` alongside the namespace entry, lying about the runtime shape (`m.Calc` is undefined) and duplicating the namespace path. The same bug applied to namespaced enums and functions which additionally emitted full declarations inside the interface body (`enum X { ... }` and `<mangled>(): T;` are not valid interface members). 3. The namespace shape landed as `export let app: { math: { Calc: typeof app__math__Calc }, };` inside the interface body, producing TS1131 (Property or signature expected) because `export let` is illegal in an interface. Fixes, scoped to the emscripten code path: * class/enum/function declarations for namespaced items lift to a pre-BindgenModule `declare ...` (module-internal). Drops the `export ` prefix on the class prelude and adds the same `declare` treatment for namespaced enums and functions, which previously emitted directly into the BindgenModule body. * the unqualified `<js_name>: typeof <mangled>;` interface entry is skipped when the item is namespaced; the namespace shape covers it. * the namespace shape emits as a plain interface member (`app: { math: { Calc: typeof app__math__Calc } };`) bypassing the `export let ` form `export_def` would otherwise produce. * the .d.ts now ends with `export { BindgenModule };` so the file is an ES module — the `declare ...` declarations become module-scoped rather than global, closing the mangled-identifier leak. Test: * `emscripten_namespaced_exports_valid_ts` covers the original deep- namespace repro (`js_namespace = ["app", "math"]` on a struct + impl with constructor and method), same-`js_name` collisions across namespaces (which require the mangled identifier as the disambiguator inside the shape), namespaced enums and free functions, and runs `tsc --noEmit --strict` on the output as the canonical validity check. CI installs typescript globally before `cargo test -p wasm-bindgen-cli` so tsc is on PATH; the test skips gracefully when tsc isn't available locally.
emscripten-output-fixes
21 hours ago
latest output fixes
emscripten-output-fixes
21 hours ago
style: cargo fmt
emscripten-output-fixes
22 hours ago
Add changelog entry for emscripten output fixes
emscripten-output-fixes
1 day ago
Fix emscripten output: dep graph, HEAP_DATA_VIEW, function declarations This implements proper emscripten library dependency tracking and fixes several latent issues in the emscripten output path so that wasm-bindgen output works against vanilla emscripten without requiring a fork. * `adapter_deps` is now cumulative across all adapter generation. Per-import `__deps` arrays are computed via snapshot/diff at the start and end of each `Import`/`Adapter` body. The cumulative set drives `$initBindgen__deps` so emcc's library tree-shaker keeps every symbol the inlined export bodies reference. * `intrinsic()` always takes a `deps: &[&str]` so every helper declares the library symbols its body references. All 45 call sites audited and given accurate deps. The dep edge is registered on `adapter_deps` every call (not just the first), so the Nth caller of a shared intrinsic correctly pulls it in. * `HEAP_DATA_VIEW` is now declared by wasm-bindgen and refreshed via wrapping `updateMemoryViews` in a postset. Upstream emscripten only declares it under `SUPPORT_BIG_ENDIAN`, so the common little-endian case previously referenced an undefined variable. * `export_to_emscripten` rewritten to handle three input shapes: pre-formatted `addToLibrary({...})` blocks pass through verbatim; `function name(args) { body }` declarations are inlined as `addToLibrary({ $name: function(args){body}, $name__deps: [...] })`; anything else is wrapped as a value initializer. This eliminates the previous dead file-scope function declarations that referenced library symbols out of scope. * The catch-wrapper transform is skipped on emscripten output. Emscripten may link wasm exception-handling instructions from libcxx/embind that have nothing to do with `#[wasm_bindgen(catch)]`, and the wasm-bindgen runtime intrinsics (`__externref_table`, `__externref_table_alloc`, `__wbindgen_exn_store`) may be absent. * Fixed `getArrayJsValueFromWasm0` and `getArrayJsValueViewFromWasm0` to use the correct heap access on emscripten (`HEAP_DATA_VIEW` vs the non-existent `HEAP_DATA_VIEW0()` form). * Interpreter and wasm-conventions handle PIC modules: imported `__stack_pointer` and `__table_base` globals are recognized; imported i32/i64 globals are seeded so descriptor execution works on emscripten-linked input.
emscripten-output-fixes
1 day ago
Merge branch 'main' into try-from-js-value-vec
try-from-js-value-vec
2 days ago

Latest Branches

CodSpeed Performance Gauge
-11%
Fix emscripten output: dep graph, HEAP_DATA_VIEW, function declarations#5156
21 hours ago
3260504
emscripten-output-fixes
CodSpeed Performance Gauge
-23%
2 days ago
41c5d27
try-from-js-value-vec
CodSpeed Performance Gauge
+11%
fix: route methods to the right class when js_name + js_namespace + js_class are combined#5154
2 days ago
3312aae
ZhaoXiangXML:fix/require-class-js-name-lookup
© 2026 CodSpeed Technology
Home Terms Privacy Docs