Repository navigation
build: package layout, tsup, vitest-runner, lint and format - #1
Merged
Merged
Conversation
Shinrai
approved these changes
Nov 25, 2026
cldmv-bot Bot
added a commit
that referenced
this pull request
Nov 26, 2026
# `@cldmv/sqlite-wasm` v0.1.0 Changelog **Release Date**: November 2026 **Release Type**: Minor (first release) **Branch**: `release/0.1.0` --- ## Overview First release of `@cldmv/sqlite-wasm`: SQLite 3.54.1 compiled to WebAssembly, with one build and one API for Node.js and browsers. Databases are real files in Node, OPFS in a browser worker, or memory anywhere, and the files are standard SQLite files that native SQLite and `node:sqlite` open as usual. The wasm is built from SQLite's own source archive with wasi-sdk and binaryen. There is no Emscripten runtime and no fork of another wasm SQLite project. CI builds it from a pinned SQLite version and hash, and nothing binary is committed. --- ## ✨ Features ### Synchronous database API on one shared wasm instance ([#2](#2)) `sqlite.open(path, options)` returns a database with prepared statements, `run` / `get` / `all` / `iterate`, transactions (nested ones become savepoints), user-defined functions, aggregates, window functions and collations, plus `backup()`, `serialize()`, `attach()` and `checkpoint()`. Every connection in a process shares one module instance, which is what lets `ATTACH` and `backup()` work between them. Every SQLite failure is a `sqlite.error` carrying the result code name (`SQLITE_CONSTRAINT_PRIMARYKEY`) and the extended code number. ### Storage drivers: `fs`, `opfs` and `memory` ([#2](#2)) - **`fs`** (Node) writes real files through synchronous `fs` calls, with `fsync` on the file and on its folder after create and delete. - **`opfs`** (dedicated browser workers) uses OPFS sync access handles, opened before SQLite needs them, so no COOP/COEP headers are needed. - **`memory`** works anywhere. Each file name keeps its data for the life of the process. - **`auto`** (the default) picks `fs` in Node and `opfs` in a dedicated worker. WAL is the default journal mode, run in exclusive locking mode so the WAL index lives in heap memory. A clean `close()` checkpoints the WAL and removes the `-wal` file. `truncate` and `delete` rollback journals are available too. ### Locking between processes and tabs ([#2](#2)) In Node, opening a database takes an owner lock outside the file, and the `lock` option picks where it lives: `beside` (a `<db>.lock/` folder, the default), `temp` (a private per-user folder under `os.tmpdir()`), a folder you name, or `db` (a row inside the database). A lock whose process is gone is taken over. In browsers, the lock is a Web Lock per database. ### Browser main thread: worker host and client ([#2](#2)) `@cldmv/sqlite-wasm/host` runs the database in a worker with `host.listen(self)`, and `@cldmv/sqlite-wasm/worker` gives the main thread an async client with the same API, including nested transactions, `backup()` and `serialize()`. A `setup(db)` hook on the host runs on every open. ### Multi-tab sharing ([#2](#2)) With `share: true`, several tabs of one origin use one OPFS database. One tab's worker owns the database and the others send their requests to it over a `BroadcastChannel`. Ownership moves through a Web Lock when that tab closes or its worker ends, with reads retried against the new owner, and writes whose outcome is unknown failing with `SQLITE_BUSY` rather than running twice. `db.info.leader` and `db.info.watch()` show which tab owns it. ### Drizzle ORM driver ([#2](#2)) `@cldmv/sqlite-wasm/drizzle` exports `drizzle()` and `migrate()` for the synchronous database (Node or inside a worker) and for the async worker client on the main thread. `drizzle-orm` `^0.45.0` is an optional peer dependency. ### What is compiled in ([#2](#2)) FTS3/4/5, R\*Tree and Geopoly, JSON, `dbstat`, math and `percentile` functions, column metadata, STAT4, and `UPDATE`/`DELETE ... ORDER BY ... LIMIT` (generated into the parser from the source archive, so Drizzle's `.orderBy()` and `.limit()` work on updates and deletes). Foreign keys are on and double-quoted strings are identifiers only. The README's "What is compiled in" section has the full list, including what is left out. --- ## 🔧 CI & tooling - **Package layout and v4 CI** ([#1](#1)): tsup build into `dist/` with a CommonJS entry that re-exports the ESM one, `@cldmv/vitest-runner` tests, eslint and prettier, and the CLDMV v4 workflow set. - **The wasm build in CI** ([#2](#2)): pinned and hash-checked downloads of SQLite's source archive, wasi-sdk and binaryen, with retries and a cache. The browser tests run headless Chromium as their own CI job, and `npm run sqlite:bump` moves the SQLite pin. - **Generated types** ([#4](#4)): `types/` is built when the package is built or packed instead of being committed, and each published declaration's header names its own file. ## 🔧 Dependencies - `drizzle-orm` `^0.45.0`: optional peer dependency, needed only for `@cldmv/sqlite-wasm/drizzle`. - No runtime dependencies. --- ## Upgrade notes - First release, nothing to upgrade from. - Node.js `>=20.19.0` at runtime. The CommonJS entry needs `require(esm)`, so `^20.19.0` or `>=22.13.0`. - Browsers need a dedicated worker with OPFS sync access handles for persistent storage. Multi-tab sharing also needs Web Locks and `BroadcastChannel`. <details> <summary>👥 Contributors</summary> - @Shinrai </details> --- <!-- coverage-start -->  | Metric | Coverage | |--------|----------| | Statements | 100.0% | | Branches | 100.0% | | Functions | 100.0% | | Lines | 100.0% | *Avg: **100.0%** · `c0f05b9` · Node lts/** <!-- coverage-end --> <!-- co-authors --> Co-authored-by: Shinrai <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
No bug fixes
📦 Dependencies
No dependency updates
🔧 Other Changes
👥 Contributors