File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { createRequire } from 'node:module'
2+
13/// Thin SQLite read-only wrapper over Node's built-in `node:sqlite` module (stable in
24/// Node 24, experimental in Node 22 / 23). Replaces the earlier `better-sqlite3` binding
35/// so the dependency graph no longer pulls in the deprecated `prebuild-install` package
46/// (issue #75). Works across Cursor and OpenCode session DBs, both of which we only read.
57
8+ const requireForSqlite = createRequire ( import . meta. url )
9+
610type Row = Record < string , unknown >
711
812export type SqliteDatabase = {
@@ -55,10 +59,7 @@ function loadDriver(): boolean {
5559 } as typeof process . emit
5660
5761 try {
58- // Dynamic require via createRequire avoids TypeScript chasing types we don't need at
59- // build time (node:sqlite landed in @types/node much later than in Node itself).
60- // eslint-disable-next-line @typescript-eslint/no-require-imports
61- const mod = eval ( 'require' ) ( 'node:sqlite' ) as { DatabaseSync : DatabaseSyncCtor }
62+ const mod = requireForSqlite ( 'node:sqlite' ) as { DatabaseSync : DatabaseSyncCtor }
6263 DatabaseSync = mod . DatabaseSync
6364 return true
6465 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments