@allbluecn/database 0.14.17 → 0.14.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/database",
3
- "version": "0.14.17",
3
+ "version": "0.14.18",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -14,6 +14,7 @@
14
14
  // 幂等:patch 标记存在即跳过。generated/ 为生成产物,重新 generate 后须重跑
15
15
  // (已挂进 generate 脚本链)。
16
16
  import { readFileSync, writeFileSync } from "node:fs";
17
+ import { createRequire } from "node:module";
17
18
  import { dirname, join } from "node:path";
18
19
  import { fileURLToPath } from "node:url";
19
20
 
@@ -38,12 +39,21 @@ if (!importRe.test(code)) {
38
39
  process.exit(1);
39
40
  }
40
41
 
41
- // 解码 wasm 文件(从内联模块读取 base64 常量;包内 node_modules symlink 直达)
42
- const base64ModulePath = join(
43
- pkgDir,
44
- "node_modules",
45
- "@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.mjs",
46
- );
42
+ // 解码 wasm 文件(从内联模块读取 base64 常量)。@prisma/client 的物理位置随
43
+ // 包管理器布局而异(npm 嵌套在包内 node_modules,pnpm 在虚拟 store 的兄弟
44
+ // node_modules)——createRequire 从本包出发走标准解析,不硬编码层级。
45
+ // 解析不到时静默跳过:本 patch 只服务 Cloudflare Workers 构建(workerd 禁
46
+ // 动态 WASM 编译);Node/Vercel/桌面消费端保持 base64 原路即可,generate
47
+ // 的本职(产出 client)在跑进这里之前已经完成,不能让消费端构建死于可选 patch。
48
+ let base64ModulePath;
49
+ try {
50
+ base64ModulePath = createRequire(join(pkgDir, "index.ts")).resolve(base64Module);
51
+ } catch {
52
+ console.warn(
53
+ "[patch-workerd-wasm] 无法从本包解析 @prisma/client 的 wasm-base64 运行时——跳过 workerd patch(非 Cloudflare 构建无需它)",
54
+ );
55
+ process.exit(0);
56
+ }
47
57
  const base64Src = readFileSync(base64ModulePath, "utf8").match(
48
58
  /"([A-Za-z0-9+/=]{100,})"/,
49
59
  );