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 (Rust)
Section titled “WASI packages (Rust)”WASI packages run inside the fishbowl filesystem and support blocking I/O. The build process requires one post-processing step.
Compile
Section titled “Compile”cargo build --target wasm32-wasip1 --releaseApply asyncify:
pnpm --filter @fishnet/build-tools run wasi-asyncify \ target/wasm32-wasip1/release/mybin.wasm \ dist/mybin.wasmWrite the JS harness
Section titled “Write the JS harness”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 }, }}Bundle for the registry
Section titled “Bundle for the registry”pnpm --filter @fishnet/registry-tools run generate-registryEmscripten packages (C/C++)
Section titled “Emscripten packages (C/C++)”emcc myprogram.c -o dist/myprogram.js \ -sASYNCIFY \ "-sASYNCIFY_IMPORTS=['wasi_snapshot_preview1.fd_read','fd_read','fd_write','__asyncjs__*']" \ -sMODULARIZE \ -sEXPORT_ES6Further reading
Section titled “Further reading”- WASI integration → — How programs interact with the VFS
- Packages architecture → — Registry bundle format, asset layout
- Porting guide → — Porting native programs to fishbowl