@allbluecn/database 0.14.13 → 0.14.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +8 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -24,6 +24,14 @@ import { PrismaClient } from "./generated/client.ts";
|
|
|
24
24
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
25
25
|
import { Prisma } from "./generated/client.ts";
|
|
26
26
|
import { registerPrismaSeam } from "@allbluecn/kernel";
|
|
27
|
+
// 静态 import pglite-init(而非 createPrismaClient 内动态 import):
|
|
28
|
+
// 动态 import 在 rolldown/nitro 的 noExternal 打包下会被拆成 `_63.mjs` 之类的
|
|
29
|
+
// 转发 chunk(`export { initPgliteClient } from "./database"`),与主模块的
|
|
30
|
+
// 顶层 await 形成循环依赖 → TLA 死锁(rolldown #9548 同族)→ /api/health 挂起
|
|
31
|
+
// → 桌面端 60s 启动超时。pglite-init 顶层无副作用(PGlite 实例化在
|
|
32
|
+
// createPglite 内、仅 DATABASE_PROVIDER=pglite 时触发),静态 import 只把
|
|
33
|
+
// PGlite 代码并入 bundle,不影响 postgresql 分支运行时。
|
|
34
|
+
import { initPgliteClient } from "./pglite-init.ts";
|
|
27
35
|
|
|
28
36
|
const globalForPrisma = globalThis as unknown as {
|
|
29
37
|
prisma: PrismaClient | undefined;
|
|
@@ -69,7 +77,6 @@ async function createPrismaClient(): Promise<PrismaClient> {
|
|
|
69
77
|
"(账号数据目录)与 PGLITE_MIGRATIONS_DIR(打包 migrations 副本)环境变量。",
|
|
70
78
|
);
|
|
71
79
|
}
|
|
72
|
-
const { initPgliteClient } = await import("./pglite-init.ts");
|
|
73
80
|
// Electron backend entry 可能已预热实例(同步引擎持有同句柄)——复用
|
|
74
81
|
const hosted = (globalThis as Record<string, unknown>).__allbluePgliteHandle as
|
|
75
82
|
| { prisma: PrismaClient }
|