Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scripts/build-sidecar-bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const jsdomStyleReadPattern = / var defaultStyleSheet = [A-Za-z_$][\w$]*\.readF
const undiciFilenamePattern = /^ var __filename = ".*node_modules.*undici.*index\.js";\r?\n/m;
const xhrWorkerResolvePattern = / var syncWorkerFile = __require\.resolve\("[^"\r\n]*xhr-sync-worker\.js"\);/;
const sqlJsDirnamePattern = /^ var __dirname = ".*node_modules.*sql\.js.*dist", __filename = ".*node_modules.*sql\.js.*dist.*sql-wasm\.js";\r?\n/m;
// @larksuiteoapi/node-sdk 的 getSdkVersion() 用 __dirname 读自身 package.json 取版本号拼 User-Agent。
// bundle 里其 package.json 不会随包发布,路径必解析失败 → 已有 try/catch 兜底返回 'unknown'。
// 把绝对路径替换成 ".",避免可重定位性自检报错;版本号降级为 'unknown' 无功能影响。
const larkSdkDirnamePattern = /^ var __dirname = ".*node_modules.*larksuiteoapi.*node-sdk.*lib";\r?\n/m;
const transformersDirnamePattern = /, __dirname = "[^"]*node_modules[^\"]*transformers[^\"]*dist", __webpack_modules__/;
const jsdomStylePath = resolve(jsdomLibDir, "jsdom", "browser", "default-stylesheet.css");
const jsdomStyle = readFileSync(jsdomStylePath, "utf8");
Expand Down Expand Up @@ -119,6 +123,14 @@ bundleSrc = bundleSrc.replace(
sqlJsDirnamePattern,
' var __dirname = ".", __filename = "sql-wasm.js";',
);
if (!larkSdkDirnamePattern.test(bundleSrc)) {
console.error("[sidecar-bundle] main: Lark SDK __dirname pattern not found");
process.exit(1);
}
bundleSrc = bundleSrc.replace(
larkSdkDirnamePattern,
' var __dirname = ".";',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid resolving Lark's version from css-tree metadata

When the desktop launches the sidecar, createUtilityProcessSidecarForkConfig sets its cwd to the bundle directory (apps/desktop/src/sidecar-process.ts:171), so replacing the SDK's lib directory with "." makes its ../package.json lookup target resources/package.json. The build explicitly places css-tree's manifest there (scripts/build-sidecar-bundle.mjs:223), meaning the lookup succeeds with css-tree's 3.2.1 version instead of taking the claimed unknown fallback; Feishu requests consequently advertise an incorrect SDK version. Use a guaranteed-missing path to preserve the fallback or inline the actual Lark SDK version.

Useful? React with 👍 / 👎.

);
if (!transformersDirnamePattern.test(localOnnxWorkerSrc)) {
console.error("[sidecar-bundle] local ONNX worker: transformers __dirname pattern not found");
process.exit(1);
Expand Down
Loading