Packages
wa_embedder_ex
0.1.0
Idiomatic Elixir wrapper over the wa_embedder WebAssembly-to-BEAM compiler (the Erlang :wa_embedder core). Compiles a .wasm binary into a native BEAM module and raises %WaEmbedder.ImportError{} on unsatisfiable imports.
Current section
Files
Jump to
Current section
Files
wa_embedder_ex
README.md
README.md
# WaEmbedderEx
Idiomatic Elixir wrapper over [`wa_embedder`](https://hex.pm/packages/wa_embedder),
the Erlang WebAssembly→BEAM compiler core. `WaEmbedder.compile/1..4` parses a
`.wasm` binary, translates it to Erlang abstract format, compiles and loads it
as a native BEAM module, and raises `%WaEmbedder.ImportError{}` on
unsatisfiable imports.
This package is a thin shim; the compiler pipeline lives in the pure-Erlang
`:wa_embedder` core (usable directly from Erlang without Elixir).
## Installation
```elixir
def deps do
[{:wa_embedder_ex, "~> 0.1"}]
end
```
## Usage
```elixir
{:module, mod} = WaEmbedder.compile("path/to/module.wasm")
mod.some_exported_fun(arg)
```
For modules with imports, pass an imports map:
```elixir
WaEmbedder.compile("mod.wasm", %{"env" => %{"add" => {MyMod, :add}}}, [])
```
## License
Unlicense (public domain). See [UNLICENSE](UNLICENSE).