An open API service indexing awesome lists of open source software.

https://github.com/jcbhmr/hello-world-rust-wasm-component-lib

🟪 Rust library compiled to WASM and distributed as a WASM component
https://github.com/jcbhmr/hello-world-rust-wasm-component-lib

component-model rust wasm wasm-component webassembly

Last synced: about 2 months ago
JSON representation

🟪 Rust library compiled to WASM and distributed as a WASM component

Awesome Lists containing this project

README

        

# "Hello world!" Rust WebAssembly component library

🟪 Rust library compiled to WASM and distributed as a [WASM component]


Download WASM
| View WIT
| JavaScript bindings

🦀 Written in Rust \
🟪 Modern WebAssembly Component example \
🌎 Runs on any [WebAssembly Component Runtime] \
📥 Imports some host functions \
📤 Exports some functions \
👩‍⚖️ [0BSD licensed](./LICENSE) template

## Usage

![WebAssembly](https://img.shields.io/static/v1?style=for-the-badge&message=WebAssembly&color=654FF0&logo=WebAssembly&logoColor=FFFFFF&label=)

To get started just [download the latest WASM artifact] and use it in your
favorite [WebAssembly Component Runtime]! Make sure you provide any required
imports! 😉

## Development

![Rust](https://img.shields.io/static/v1?style=for-the-badge&message=Rust&color=000000&logo=Rust&logoColor=FFFFFF&label=)
![WebAssembly](https://img.shields.io/static/v1?style=for-the-badge&message=WebAssembly&color=654FF0&logo=WebAssembly&logoColor=FFFFFF&label=)

```sh
./just build
```

ℹ You'll need [`wasm-tools`] installed which you can get via
`cargo install wasm-tools`.

You can inspect the output component WASM using something like this:

```sh
wasm-tools component wit target/wasm32-wasi/debug/*.wasm
#=> world my-component {
# import print: func(msg: string)
# export run: func()
# }
```

The `wasi_snapshot_preview1.reactor.wasm` is the adapter module to shim the
component API over top of the existing WASI API. Keep it updated from
[bytecodealliance/wasmtime releases]. Since this is a library we want the
"reactor" version.

🚚 To create a new release, don't use the GitHub UI directly; use the [draft
release] GitHub Actions workflow to create the initial draft release with the
compiled WASM artifact. Then you can edit that release and publish it as normal.
Make sure the `version` fields are correct before drafting the release; it's
used to choose the `v${version}` tag name for the release and in publishing.
Also try not to change the artifacts attached to the draft release; they are
generated by GitHub Actions.

[webassembly component runtime]: https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components
[wasm component]: https://github.com/WebAssembly/component-model
[`wasm-tools`]: https://github.com/bytecodealliance/wasm-tools
[bytecodealliance/wasmtime releases]: https://github.com/bytecodealliance/wasmtime/releases
[draft release]: https://github.com/jcbhmr/hello-world-wasm-component/actions/workflows/draft-release.yml
[download the latest WASM artifact]: https://github.com/jcbhmr/hello-world-rust-wasm-component-lib/releases/latest/download/hello_world_rust_wasm_component_lib.wasm