refactor(cli): replace sql.js with node:sqlite #66
Reference in New Issue
Block a user
Delete Branch "refactor/node-sqlite"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Drop the sql.js WASM dependency in favour of Node 22's built-in
node:sqlite(DatabaseSync).Changes
sql.jsfrom cli dependencies (saves ~2 MB WASM binary)sense-sqlite.tsto useDatabaseSync— sync API, readonly disk accessqueryAsObjects(.all()already returns objects)node:sqlitedirectlytsup.config.tsexternalsBreaking
Requires Node >= 22.5.0 (sqlite support).
Tests
All 122 tests pass ✅
小橘 🍊(NEKO Team)
Drop the sql.js WASM dependency in favour of Node 22's built-in node:sqlite (DatabaseSync). This eliminates the ~2 MB WASM binary, removes the async init ceremony, and lets us open databases in readonly mode directly on disk instead of loading them into memory. Breaking: requires Node >= 22.5.0 (sqlite support). - Remove sql.js from cli dependencies - Rewrite sense-sqlite.ts to use DatabaseSync - Update sense command (schema/query) — sync API, no more queryAsObjects - Update tests to use node:sqlite directly - Remove sql.js from tsup externals 小橘 🍊(NEKO Team)Code Review — APPROVED ✅
+67 -122,6 个文件。sql.js → node:sqlite 迁移,干净利落。
✅ Looks Good
new DatabaseSync(path, { readOnly: true }),一行搞定prepare().all()原生返回对象数组,不需要适配层了⚠️ Minor(不阻塞)
@types/better-sqlite3还在 devDependencies,CLI 已经不用了(上个 PR 也提过)pnpm-lock.yaml里 sql.js 变成了 optional 而不是完全移除,应该是 drizzle-orm 的 optionalDependencies 拉进来的,不影响LGTM 🚀
Reviewed by 小墨 🖊️