Skip to content

Build & Distribute

What you’ll build: A Rust program compiled to WASI and packaged as a fishbowl package.

Prerequisites: Custom Package →, Rust toolchain with wasm32-wasip1 target


WASI packages run inside the fishbowl filesystem and support blocking I/O. The build process requires one post-processing step.

target/wasm32-wasip1/release/mybin.wasm
cargo build --target wasm32-wasip1 --release

Apply asyncify:

Terminal window
pnpm --filter @fishnet/build-tools run wasi-asyncify \
target/wasm32-wasip1/release/mybin.wasm \
dist/mybin.wasm
src/index.ts
import { createWasiBin } from '@fishnet/runtime/wasm'
import type { Extension } from '@fishnet/core'
export default function myWasiPackage(): Extension {
return {
bins: {
mybin: createWasiBin(import.meta.url),
// Resolves mybin.wasm from the same directory as this file
},
}
}
Terminal window
pnpm --filter @fishnet/registry-tools run generate-registry
Terminal window
emcc myprogram.c -o dist/myprogram.js \
-sASYNCIFY \
"-sASYNCIFY_IMPORTS=['wasi_snapshot_preview1.fd_read','fd_read','fd_write','__asyncjs__*']" \
-sMODULARIZE \
-sEXPORT_ES6