- 删除 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>
22 lines
595 B
TypeScript
22 lines
595 B
TypeScript
#!/usr/bin/env bun
|
|
/**
|
|
* Dev entrypoint — launches cli.tsx with MACRO.* defines injected
|
|
* via Bun's -d flag (bunfig.toml [define] doesn't propagate to
|
|
* dynamically imported modules at runtime).
|
|
*/
|
|
import { getMacroDefines } from "./defines.ts";
|
|
|
|
const defines = getMacroDefines();
|
|
|
|
const defineArgs = Object.entries(defines).flatMap(([k, v]) => [
|
|
"-d",
|
|
`${k}:${v}`,
|
|
]);
|
|
|
|
const result = Bun.spawnSync(
|
|
["bun", "run", ...defineArgs, "src/entrypoints/cli.tsx", ...process.argv.slice(2)],
|
|
{ stdio: ["inherit", "inherit", "inherit"] },
|
|
);
|
|
|
|
process.exit(result.exitCode ?? 0);
|