WaEmbedder (WaEmbedderEx v0.1.0)

Copy Markdown View Source

WebAssembly -> BEAM compiler (Elixir-facing API).

The compiler pipeline lives in the pure-Erlang :wa_embedder core; this module is a thin wrapper that delegates compile/1..4 to it and translates the core's {:import_error, map} error into a %WaEmbedder.ImportError{} exception for Elixir callers. Erlang consumers can call :wa_embedder directly without any Elixir dependency.

Summary

Functions

Compile and load a .wasm file, deriving the module name from its path.

compile/2 accepts either an options list (compile(path, opts)) or an imports map (compile(path, imports_map)); both are forwarded to the core.

Primary entry point for modules that declare imports. imports_map maps WASM import module/name to Erlang targets, e.g. %{"env" => %{"add" => {MyMod, :add}}} (MFA tuples, &Mod.fun/arity captures, or closures).

Functions

compile(filepath)

Compile and load a .wasm file, deriving the module name from its path.

compile(filepath, opts_or_imports)

compile/2 accepts either an options list (compile(path, opts)) or an imports map (compile(path, imports_map)); both are forwarded to the core.

compile(filepath, imports_map, opts)

Primary entry point for modules that declare imports. imports_map maps WASM import module/name to Erlang targets, e.g. %{"env" => %{"add" => {MyMod, :add}}} (MFA tuples, &Mod.fun/arity captures, or closures).