Skip to content
edgesync WASM Targets
Login

WASM Targets

EdgeSync ships two WebAssembly builds. Both are produced by the leaf module — same agent API (New -> Start -> Stop) — but with different runtimes, networking models, and SQLite drivers.

Target GOOS GOARCH SQLite driver Build entry Output
WASI wasip1 wasm ncruces (WASM-based) leaf/cmd/leaf bin/leaf.wasm
Browser js wasm ncruces + OPFS VFS leaf/cmd/wasm bin/leaf-browser.wasm + bin/wasm_exec.js

Building

Both targets are driven from the repo root:

make wasm-wasi      # produces bin/leaf.wasm
make wasm-browser   # produces bin/leaf-browser.wasm and copies wasm_exec.js
make wasm           # both

The Makefile cds into leaf/ because the leaf agent lives in its own Go module. The browser recipe copies wasm_exec.js from $(go env GOROOT)/lib/wasm/ (Go 1.26+ path); older Go releases used misc/wasm/.

SQLite driver selection

leaf/cmd/leaf/main.go uses build-tagged blank imports to pick the right driver:

The browser entry (leaf/cmd/wasm/main.go) is //go:build js and imports ncruces directly.

Runtimes

Known limitations

See agent-deployment.md (WASM Targets section) for the agent lifecycle in WASM and testing-strategy.md for how WASM builds are exercised in CI.