mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
refactor: 用 Bun 原生 define 替换 cli.tsx 中的 globalThis 注入
- 删除 cli.tsx 顶部的 globalThis.MACRO / BUILD_* / feature polyfill - 新增 scripts/defines.ts 作为 MACRO define 映射的单一来源 - 新增 scripts/dev.ts,通过 bun run -d 在转译时注入 MACRO 常量 - build.ts 引用 getMacroDefines() 实现构建时内联 - 清理 global.d.ts (移除 BUILD_*, MACRO 函数声明) - 55 个 MACRO 消费文件零改动 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
18
scripts/defines.ts
Normal file
18
scripts/defines.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Shared MACRO define map used by both dev.ts (runtime -d flags)
|
||||
* and build.ts (Bun.build define option).
|
||||
*
|
||||
* Each value is a JSON-stringified expression that replaces the
|
||||
* corresponding MACRO.* identifier at transpile / bundle time.
|
||||
*/
|
||||
export function getMacroDefines(): Record<string, string> {
|
||||
return {
|
||||
"MACRO.VERSION": JSON.stringify("2.1.888"),
|
||||
"MACRO.BUILD_TIME": JSON.stringify(new Date().toISOString()),
|
||||
"MACRO.FEEDBACK_CHANNEL": JSON.stringify(""),
|
||||
"MACRO.ISSUES_EXPLAINER": JSON.stringify(""),
|
||||
"MACRO.NATIVE_PACKAGE_URL": JSON.stringify(""),
|
||||
"MACRO.PACKAGE_URL": JSON.stringify(""),
|
||||
"MACRO.VERSION_CHANGELOG": JSON.stringify(""),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user