瀏覽代碼

fix: hide bun:sqlite import from tsc on Node.js builds

Concatenate the module specifier at runtime ('bun:' + 'sqlite') so tsc
doesn't try to resolve it during compilation on Node.js CI runners.
Tobi Lutke 3 月之前
父節點
當前提交
8dd6cdcebf
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/db.ts

+ 3 - 1
src/db.ts

@@ -12,7 +12,9 @@ let _Database: any;
 let _sqliteVecLoad: (db: any) => void;
 
 if (isBun) {
-  _Database = (await import("bun:sqlite")).Database;
+  // Dynamic string prevents tsc from resolving bun:sqlite on Node.js builds
+  const bunSqlite = "bun:" + "sqlite";
+  _Database = (await import(/* @vite-ignore */ bunSqlite)).Database;
   const { getLoadablePath } = await import("sqlite-vec");
   _sqliteVecLoad = (db: any) => db.loadExtension(getLoadablePath());
 } else {