js-component-bindgen 2.17.0

JS component bindgen for transpiling WebAssembly components into JavaScript
Documentation

Installation

$ cargo add js-component-bindgen

Generated JavaScript includes its runtime intrinsics inline by default. To select an external runtime provider, enable the opt-in external-runtime Cargo feature, call transpile_with_config, and set TranspileConfig::cm_runtime_es_module to @bytecodealliance/jco-cm-runtime or another module specifier. Make the selected module resolvable from the generated output; it must export a runtime provider. Currently, external providers implement resource.tableGet, while the remaining intrinsics are generated inline.

[dependencies]
js-component-bindgen = { version = "2.17", features = ["external-runtime"] }
use js_component_bindgen::{TranspileConfig, TranspileOpts, transpile_with_config};

let config = TranspileConfig::builder()
    .opts(TranspileOpts::builder().name("component".into()).build())
    .cm_runtime_es_module("@bytecodealliance/jco-cm-runtime".into())
    .build();
let transpiled = transpile_with_config(component, config)?;

The existing transpile(component, opts) API and TranspileOpts struct literals remain supported. TranspileConfig is non-exhaustive so future configuration fields can be added without breaking callers; construct it with its builder or Default.

The separate opt-in coop-threads Cargo feature exposes the thread-named Intrinsic aliases, such as Intrinsic::GlobalCurrentThreadMeta. The published task-named variants remain available for exhaustive matches. This feature is independent of external-runtime; it controls the public Rust names and does not change the generated JavaScript.

License

This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.