feat(sdk): 版本注入与事件归属骨架(0.2.0/build_id/schema_version)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
+13
-2
@@ -1,6 +1,17 @@
|
||||
import { build } from "esbuild";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
let buildId;
|
||||
try {
|
||||
buildId = execSync("git log -1 --format=%h-%cd --date=format:%Y%m%d%H%M").toString().trim();
|
||||
} catch {
|
||||
buildId = "dev-" + Date.now();
|
||||
}
|
||||
|
||||
await build({
|
||||
entryPoints: ["src/index.ts"],
|
||||
bundle: true, minify: true, format: "iife",
|
||||
entryPoints: ["src/index.ts"], bundle: true, minify: true, format: "iife",
|
||||
outfile: "dist/v1.js", target: ["es2020"], // 代码依赖 globalThis(es2018 目标名不副实)
|
||||
// define 键必须用点链:esbuild 只做精确表达式匹配,裸键不会替换
|
||||
// globalThis.__BUILD_ID__ 成员访问(实测 0.24.2),裸键将恒为 "unknown"
|
||||
define: { "globalThis.__BUILD_ID__": JSON.stringify(buildId) },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user