@dolthub/doltlite-wasm

中文文档
0.51.11发布于 2026/11/12Apache-2.0ES Module零依赖近 30 天下载 2422

DoltLite compiled to WebAssembly: SQLite with Dolt-style version control (branches, commits, merge, diff) for the browser and any JS runtime.

原始使用文档
文档目录5 节
  1. Install
  2. Browser (OPFS-backed, persistent)
  3. Node / Bun
  4. Entry points
  5. License

@dolthub/doltlite-wasm

DoltLite compiled to WebAssembly: a drop-in SQLite build with Dolt-style version control — dolt_commit, dolt_branch, dolt_merge, dolt_diff, and the rest — that runs in the browser and in any JS runtime.

This is the WebAssembly distribution. For a native Node/Bun addon, use @dolthub/doltlite instead.

Install

npm install @dolthub/doltlite-wasm

Browser (OPFS-backed, persistent)

OPFS persistence requires the page be served cross-origin isolated (the COOP/COEP headers below); without them you still get an in-memory database.

import { sqlite3InitModule } from '@dolthub/doltlite-wasm';

const sqlite3 = await sqlite3InitModule();

// OpfsDb exists only after the OPFS VFS installs. sqlite3.opfs is removed
// during init, so ('opfs' in sqlite3) stays false even when OPFS is ready.
const db = sqlite3.oo1.OpfsDb
  ? new sqlite3.oo1.OpfsDb('/app.db')
  : new sqlite3.oo1.DB(':memory:');

db.exec(`CREATE TABLE IF NOT EXISTS t(id INTEGER PRIMARY KEY, msg TEXT)`);
db.exec(`INSERT INTO t(msg) VALUES('hello')`);
db.exec(`SELECT dolt_commit('-A', '-m', 'first commit')`);

for (const row of db.selectObjects(`SELECT * FROM dolt_log`)) {
  console.log(row.commit_hash, row.message);
}

Required headers for OPFS (cross-origin isolation):

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Node / Bun

import { sqlite3InitModule } from '@dolthub/doltlite-wasm';

const sqlite3 = await sqlite3InitModule();
const db = new sqlite3.oo1.DB(':memory:');
db.exec(`CREATE TABLE t(x)`);
db.exec(`SELECT dolt_commit('-A', '-m', 'init')`);

That import loads the Node build under Node and the bundler build in a browser. Paths are process-local. For persistence, serialize or use native @dolthub/doltlite.

Entry points

ImportUse
@dolthub/doltlite-wasmNode build under Node; bundler-friendly ESM otherwise
@dolthub/doltlite-wasm/sqlite3.mjsPlain ESM (no bundler)
@dolthub/doltlite-wasm/sqlite3-node.mjsNode-specific entry
@dolthub/doltlite-wasm/sqlite3-worker1-promiser.mjsWorker promiser API

The JavaScript API is the upstream SQLite WASM API — see the sqlite3-wasm docs. Everything there works; DoltLite adds the dolt_* version-control functions and virtual tables on top.

License

Apache-2.0. See LICENSE.md. SQLite itself is public domain.

版本与发布记录

@dolthub/doltlite-wasm 共发布 73 个版本,首次发布于 2026/06/24;过去 12 个月发布了 73 个版本。

版本发布日期距今
0.51.11latest2026/11/121 天前
0.51.102026/11/094 天前
0.51.92026/11/067 天前
0.51.82026/11/058 天前
0.51.72026/11/049 天前
0.51.62026/11/0211 天前

关于 @dolthub/doltlite-wasm 的常见问题

@dolthub/doltlite-wasm 是什么?

DoltLite compiled to WebAssembly: SQLite with Dolt-style version control (branches, commits, merge, diff) for the browser and any JS runtime.

如何安装 @dolthub/doltlite-wasm?

在项目目录运行 npm install @dolthub/doltlite-wasm,或使用 pnpm add / yarn add / bun add。

@dolthub/doltlite-wasm 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dolthub__doltlite-wasm 是否存在。

@dolthub/doltlite-wasm 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dolthub/doltlite-wasm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dolthub/doltlite-wasm 可以商用吗?

@dolthub/doltlite-wasm 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dolthub/doltlite-wasm 的下载量有多少?

根据 npm 官方下载统计,@dolthub/doltlite-wasm 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,422 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dolthub/doltlite-wasm 还在维护吗?

最新版本 0.51.11 发布于 2026/11/12(1 天前);至今共发布 73 个版本,其中过去 12 个月发布了 73 个;首次发布于 2026/06/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。