WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.42k stars 393 forks source link

Doesn't work with Bun #1246

Closed ad-si closed 3 weeks ago

ad-si commented 4 weeks ago
mkdir bun-test
cd bun-test
touch index.ts

Insert this content into index.ts

import Database from "better-sqlite3"

const db = new Database(":memory:")
db.exec(`
  CREATE TABLE "users" (
    "name" TEXT
  )
`)
db.exec(`
  INSERT INTO "users" ("name")
  VALUES ('John')
`)
const result = db.prepare(`SELECT * FROM "users"`).get()

console.info(result)
bun install
bun run index.ts

Outputs this error:

dyld[27961]: missing symbol called

My OS: macOS Sonoma 14.6.1 arm64 Bun version: 1.1.26

neoxpert commented 4 weeks ago

The native part of better-sqlite3 (C++) is compiled against the NodeJS and Electron Apis. So either Bun supports one of those APIs completely or it has to offer it's own API to compile / link against. Afaik there are still issues with loading native modules that are compiled for NodeJS while stating they should be usable.

If Bun is the target runtime, using its built-in Sqlite3 driver would be more useful I guess.

mceachen commented 3 weeks ago

@neoxpert :100: -- if I had to guess, I don't suspect @JoshuaWise will be adding native code to support the bun runtime -- but if he'd like to, he's certainly free to reopen this!