Artifact 762a5c3e6f174c144e96a69ea6ade6b79c34d8bcbd835b26bd6e643b4b370b9d:
- File
examples/tinygo/README.md
— part of check-in
[0650171d55]
at
2026-10-23 21:25:20
on branch main
— feat(wasm): build the whole public API with TinyGo
go-libfossil compiled for js/wasm only with the standard toolchain, whose output is about 16 MB, too large to ship with a page or an edge function. Three standard-library features TinyGo lacks kept it from building there: http.ErrUseLastResponse and net.DNSError in the sync client, and os.SameFile in checkout-marker recovery.
Each now sits behind a tinygo build tag. Under TinyGo a sync redirect ends the request with an error instead of being followed, DNS failures are not classified as transient, and two names of one checkout marker are reported as ambiguous rather than paired; the standard build is unchanged.
examples/tinygo exercises the whole public API, sync and signing included. Built with TinyGo 0.43 and wasm-opt -Oz it is 3.83 MB raw and 1.40 MB gzipped, against 16.1 MB and 4.06 MB from the standard toolchain. A new CI job builds it with TinyGo on every change. (user: [email protected], size: 1269) [annotate] [blame] [check-ins using] [more...]
# tinygo (js/wasm) The whole public API, including the HTTP sync client and signing, compiled with [TinyGo](https://tinygo.org) for the `wasm` (js) target. ``` tinygo build -target=wasm -no-debug -opt=z -stack-size=1MB -o libfossil.wasm ./examples/tinygo/ wasm-opt -Oz --detect-features --strip-debug --strip-producers libfossil.wasm -o libfossil.wasm ``` `-stack-size=1MB`: TinyGo's default goroutine stack is too small for go-libfossil's deeper paths. Measured on TinyGo 0.43.0 (Go 1.27.3, LLVM 22) and Binaryen 133, for this program: | Build | Raw | gzip -9 | |---|---|---| | TinyGo, then `wasm-opt -Oz` | 3.83 MB | 1.40 MB | | TinyGo | 4.02 MB | 1.44 MB | | Standard Go, `GOOS=js GOARCH=wasm -ldflags='-s -w'` | 16.1 MB | 4.06 MB | A program that leaves out sync (no `net/http`, no TLS) is smaller. No SQLite driver is imported here. A TinyGo host registers a `database/sql` driver over its own SQLite. The `ncruces` driver runs SQLite as an embedded wasm module and is for standard Go builds; the `modernc` driver has no wasm build. Under TinyGo two things behave differently, because TinyGo's standard library lacks what they use: a sync redirect ends the request with an error instead of being followed, and DNS failures are not classified as transient.