fix: use bun:sqlite in production, better-sqlite3 as test-only devDep
Production (Docker): src/lib/db.ts now uses bun:sqlite + drizzle-orm/bun-sqlite. No native addon compilation needed — bun:sqlite is a Bun built-in. The Dockerfile drops all native build tools (python3, make, g++) and uses --ignore-scripts. Tests (Vitest/Node.js): bun:sqlite is unavailable under Node.js, so: - tests/helpers/db.ts keeps better-sqlite3 + drizzle-orm/better-sqlite3 for integration tests that need a real in-memory SQLite - vitest.config.ts aliases bun:sqlite → a thin better-sqlite3 shim and drizzle-orm/bun-sqlite → drizzle-orm/better-sqlite3 for unit tests that transitively import src/lib/db.ts without executing any queries - better-sqlite3 stays as a devDependency (test-only, not built in Docker) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
6
tests/helpers/bun-sqlite-compat.ts
Normal file
6
tests/helpers/bun-sqlite-compat.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Vitest-only shim: maps bun:sqlite's named Database export to better-sqlite3.
|
||||
// Used via resolve.alias in vitest.config.ts so tests that transitively import
|
||||
// src/lib/db.ts (which uses bun:sqlite) don't fail under Node.js.
|
||||
// No actual queries run via this path in the affected tests (DATABASE_URL=:memory:
|
||||
// skips migrations, and the tested functions don't touch the database).
|
||||
export { default as Database } from 'better-sqlite3';
|
||||
Reference in New Issue
Block a user