Skip to content

refactor: replace better-sqlite3 with built-in node:sqlite - #32

Open
sdirix wants to merge 1 commit into
nilbuild:mainfrom
sdirix:refactor/node-sqlite
Open

refactor: replace better-sqlite3 with built-in node:sqlite#32
sdirix wants to merge 1 commit into
nilbuild:mainfrom
sdirix:refactor/node-sqlite

Conversation

@sdirix

@sdirix sdirix commented Jul 25, 2026

Copy link
Copy Markdown

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)

As Node 18 and 20 are EOL already I think this is a good opportunity to slim down diffity. This makes life easier as diffity does not have to be rebuilt for every Node version. You might want to increase the major version before releasing to indicate breaking changes for users still using older Node versions.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant