Building and releasing
Two scripts at the repository root do the building: build.sh checks and tests
the library, and build-site.sh builds this book into docs/. The release
itself is a short manual process, written down in
MAINT.md.
build.sh
In order, it:
- Updates the toolchain:
rustup update, thencargo install mdbook. - Rebuilds the WebAssembly module with
./swift/build.shif anything underswift/is newer thanwasm/flatdata.wasm, and embeds it withtools/embed-wasm.ts(below). - Updates every dependency to its latest version with
deno update --latest. The versions indeno.jsonare pinned exactly, so this is the only thing that moves them; review the diff. - Formats the Markdown and TypeScript with
deno fmt. - Runs
deno lintanddeno checkon the TypeScript. - Runs the tests in
./testswith--allow-runlimited to the commands they use, and then the benchmarks intests/comprehensive_benchmarks.test.ts.
It stops at the first failure (set -e).
The WebAssembly module
The CSV and TSV readers and the CSV-TSV converters run in WebAssembly built from
Embedded Swift in swift/. swift/build.sh compiles the package in release
mode with the Embedded WebAssembly SDK (SWIFT_SDK names another) and copies
the result to wasm/flatdata.wasm. swift/Package.swift explains the compiler
flags: SIMD on for the Swift code too, and no stack protector, which keeps the
module free of imports. tools/embed-wasm.ts then writes the file,
base64-encoded, into src/wasm/flatdata-wasm.ts, which is what the library
loads: a package installed from JSR has https: module URLs and can’t read a
.wasm file next to it.
Both the .wasm and the generated .ts are committed, so Swift is needed only
when something under swift/ changes, and build.sh skips the build otherwise:
the compiler embeds a hash that differs on every build, so rebuilding unchanged
sources would still change the bytes. To see what the compiler made of a loop,
disassemble the module with llvm-objdump -d wasm/flatdata.wasm. If the two
files ever disagree, tests/packaging.test.ts fails and says to run
tools/embed-wasm.ts.
build-site.sh
- Updates
rustupand mdBook, asbuild.shdoes. - Generates the HTML API docs with
deno doc --htmlintosite/src/api-docs/. - Formats the book’s Markdown and TypeScript.
- Builds the book with
mdbook build, usingsite/book.toml. Two preprocessors run:site/gitv.tsfills in the version placeholder (gitvin double braces) with the latest git tag, andtools/mdbook-deno-script-preprocessor.tsruns<script>blocks in pages (see its.mdfile). - Replaces
docs/with the built site. GitHub Pages servesdocs/frommain. - Writes
llms.txt(an index of the pages) andllms-full.txt(the whole book, examples and output included) intodocs/withtools/llms-txt.ts, for LLMs, which read those more reliably than HTML.
Because the version shown in the book comes from the latest tag, build the site
after tagging a release, not before. Commit docs/ on its own: the generated
files make a noisy diff that shouldn’t hide source changes.
Releasing
MAINT.md has the
commands. In outline: set the version in deno.json (JSR takes it from there),
commit, tag that commit with the same version and push the tag, run
deno publish, build and commit the site, and finally import the new version in
a clean directory to check the published package, since the tests only ever see
local files.