src.nth.io/

summaryrefslogtreecommitdiff
path: root/src/sqlite-lazy.ts
blob: 587f662a870a9ba1452ca55a4bfd8db8d54e8870 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Lazy stand-in for node:sqlite, used only by the esbuild bundle (via
 * --alias:node:sqlite=./dist/sqlite-lazy.js).
 *
 * In an ESM bundle, external imports are hoisted and evaluated before any
 * bundled code runs, so a direct node:sqlite import would fire Node's
 * ExperimentalWarning before the filter in warnings.ts is installed. This
 * module loads node:sqlite with require() at module-initialization time
 * instead, which the bundle defers until after the filter is active.
 */
import { createRequire } from "node:module";

const nodeRequire = createRequire(import.meta.url);
const sqlite = nodeRequire("node:sqlite") as typeof import("node:sqlite");

export const DatabaseSync = sqlite.DatabaseSync;
export const StatementSync = sqlite.StatementSync;