2026-01-14 05:40:03 +00:00
|
|
|
import { createRequire } from "node:module";
|
2026-02-08 04:53:31 -08:00
|
|
|
import { installProcessWarningFilter } from "../infra/warning-filter.js";
|
2026-01-24 10:48:33 +00:00
|
|
|
|
2026-01-14 05:40:03 +00:00
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
|
|
|
|
|
|
export function requireNodeSqlite(): typeof import("node:sqlite") {
|
2026-01-24 10:48:33 +00:00
|
|
|
installProcessWarningFilter();
|
2026-02-15 01:10:10 +01:00
|
|
|
try {
|
|
|
|
|
return require("node:sqlite") as typeof import("node:sqlite");
|
|
|
|
|
} catch (err) {
|
|
|
|
|
const message = err instanceof Error ? err.message : String(err);
|
|
|
|
|
// Node distributions can ship without the experimental builtin SQLite module.
|
|
|
|
|
// Surface an actionable error instead of the generic "unknown builtin module".
|
|
|
|
|
throw new Error(
|
|
|
|
|
`SQLite support is unavailable in this Node runtime (missing node:sqlite). ${message}`,
|
|
|
|
|
{ cause: err },
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-14 05:40:03 +00:00
|
|
|
}
|