@allbluecn/database 0.14.12 → 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.
@@ -48,15 +48,8 @@ config.compilerWasm = {
48
48
  getRuntime: async () => await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.mjs"),
49
49
 
50
50
  getQueryCompilerWasmModule: async () => {
51
- // PRISMA_WORKERD_WASM_PATCH_V1: workerd 禁动态 WASM 编译(prisma/orm#28657),
52
- // Cloudflare-Workers 环境走 vite-plugin 处理的 wasm 模块导入;
53
- // Node/Vercel/desktop 保持 base64 原路(decodeBase64AsWasm)。
54
- if (typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") {
55
- const wasmNs = (await import("../prisma-query-compiler.postgresql.wasm")) as unknown as { default: WebAssembly.Module };
56
- return wasmNs.default ?? (wasmNs as unknown as WebAssembly.Module);
57
- }
58
- const { wasm } = await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.mjs");
59
- return await decodeBase64AsWasm(wasm)
51
+ const { wasm } = await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.mjs")
52
+ return await decodeBase64AsWasm(wasm)
60
53
  },
61
54
 
62
55
  importName: "./query_compiler_fast_bg.js"
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 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/database",
3
- "version": "0.14.12",
3
+ "version": "0.14.14",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "main": "./index.ts",