wasm_node

command
v0.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

README

tinySQL WASM Node.js (wasm_node)

Compiles tinySQL to WebAssembly for Node.js. wasm_runner.js bootstraps the module and exposes the engine to Node scripts and the command line.

Build

cd cmd/wasm_node

# Build only (produces tinySQL.wasm + wasm_exec.js)
./build.sh --build-only

# Build and run the built-in demo
./build.sh --run
./build.sh --run --query "SELECT 42"

# Run existing assets without rebuilding
./build.sh --skip-build --run

Manual equivalent:

cd cmd/wasm_node
GOOS=js GOARCH=wasm go build -o tinySQL.wasm .
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" ./

Run

node wasm_runner.js                                             # status (default)
node wasm_runner.js query "SELECT 1 AS n, 'hello' AS greeting"
node wasm_runner.js exec "CREATE TABLE t (id INT)"

The runner starts the Go runtime asynchronously and waits until the global tinySQL API is ready, then opens an in-memory database, runs the command, and closes it again.

Embed in your own Node script

Use wasm_runner.js as the bootstrap reference: instantiate tinySQL.wasm, call go.run(instance) without awaiting its never-ending runtime promise, and wait for global.tinySQL. The runner is a CLI helper, not a CommonJS module.

Notes

  • Requires Node.js 18+ (WebAssembly support).
  • The database is in-memory and does not persist between Node process runs.
  • Builds use stripped symbols and optionally wasm-opt when Binaryen is installed.
  • For the browser variant see ../wasm_browser/.

Documentation

Rendered for js/wasm
The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL