refactor: replace better-sqlite3 with built-in node:sqlite (upstream #32) - #2
Merged
Conversation
Drops the only native dependency, so installs no longer risk a node-gyp
build on platforms without prebuilt binaries (and the tree shrinks by
12 MB). Same SQLite file format, so existing reviews.db files keep
working without migration.
- db.ts uses DatabaseSync, loaded lazily via createRequire so users on
older Node get a readable error instead of ERR_UNKNOWN_BUILTIN_MODULE
at startup; db.pragma(x) becomes db.exec('PRAGMA ' + x)
- add queryAll/queryOne helpers that keep the row-shape assertion in one
place, since node:sqlite types every row as Record<string,
SQLOutputValue> with no generic overloads; all row-returning queries
in threads/tours/session go through them
- doctor checks node:sqlite availability instead of native module load
- engines.node >=18 -> >=22.13 (first release with node:sqlite unflagged)
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.
Merges upstream nilbuild/diffity#32 by @sdirix unmodified.
Drops
better-sqlite3, the only native dependency, for the built-innode:sqlite. Same SQLitefile format, so existing
reviews.dbsessions keep working.engines.nodegoes>=18→>=22.13.Taken in early because it rewrites every row-returning query in
db.ts,threads.ts,tours.tsand
session.ts— the files the walkthrough work touches next.Verified locally: 127 tests pass, build succeeds, and the CLI opens the database at runtime
(
diffity list).Stacked on #1.
🤖 Generated with Claude Code
https://claude.ai/code/session_018PkYQzbsnMihHesafWvXKs