createWasmBin
Implementation signature for createWasmBin (overloads above are public).
Returns a closure-captured BinFunction that lazy-loads WASM bytes +
glue factory on first call, memoizes them for subsequent calls, and
resolves dynamic preloadPaths per invocation (callers can compute the
preload list from proc.env or other context).
The guest-side branch asserts the glue module’s default export is callable —
a non-function default means the .mjs file was packaged wrong and the
program would crash inside Emscripten’s internals otherwise.
Call Signature
Section titled “Call Signature”createWasmBin(
metaUrl,wasmFile,glueFile,opts?):BinFunction
Defined in: packages/runtime/src/wasm/create-wasm-bin.ts:112
Build a BinFunction that runs an Emscripten WASM program.
Overloads:
- Host-side — pass
import.meta.urland paths relative to it. Resolved vianode:fs/ dynamicimporton Node, andfetch/ dynamicimportin the browser. - Guest-side (registry) — pass an AssetResolver, which reads the bundled assets shipped alongside the package.
The bin caches the compiled WASM bytes and the glue factory on first call, so subsequent invocations skip asset loading.
Parameters
Section titled “Parameters”metaUrl
Section titled “metaUrl”string
wasmFile
Section titled “wasmFile”string
glueFile
Section titled “glueFile”string
CreateWasmBinOptions
Returns
Section titled “Returns”Examples
Section titled “Examples”// Host-sideexport const vimBin = createWasmBin( import.meta.url, 'vim.wasm', 'vim.mjs', { ttyMode: 'raw', preloadPaths: ['/etc/vimrc'] },)// Guest-side (registry catalog entry)export default (resolver: AssetResolver) => ({ bins: { vim: createWasmBin(resolver, 'vim.wasm', 'vim.mjs', { ttyMode: 'raw' }) },})Call Signature
Section titled “Call Signature”createWasmBin(
resolver,wasmFile,glueFile,opts?):BinFunction
Defined in: packages/runtime/src/wasm/create-wasm-bin.ts:119
Guest-side overload — resolve WASM + glue via an AssetResolver.
Parameters
Section titled “Parameters”resolver
Section titled “resolver”wasmFile
Section titled “wasmFile”string
glueFile
Section titled “glueFile”string
CreateWasmBinOptions