pglite
pglite copied to clipboard
[Bug] Bun bundle not work with PgLite
What versions are running ?
- Bun: 1.1.33
- PgLite: 0.2.12
What steps can reproduce the bug ?
Use the following index.ts and package.json files and run
bun build --compile --sourcemap ./index.ts --outfile executable && ./executable
index.ts
import { PGlite } from "@electric-sql/pglite";
const db = new PGlite();
await db.waitReady;
const result = await db.query("select 'Hello world' as message;");
console.log(result);
await db.close();
package.json
{
"name": "pglite-bundle",
"private": true,
"module": "index.ts",
"type": "module",
"dependencies": {
"@electric-sql/pglite": "0.2.12"
}
}
What is the expected behavior ?
The process runs successfully.
What do you see instead ?
The process fails with error
ENOENT: No such file or directory
errno: -2
syscall: "open"
path: "/$bunfs/root/postgres.data"
/$bunfs/root/postgres.data is a bun generated path and it is wrong. Just dont use compile until they fix packager ( afaik there are open issues already https://github.com/oven-sh/bun/issues?q=is%3Aissue%20%2F%24bunfs%2Froot )
I did this workaround (it should work for both esbuild and bun)