bun-macros
仓库创建 2025年11月8日最近提交 29 天前SkillHot 收录 22 天前
▸ 精选理由
适合需要编译时生成/内联数据以优化运行时的场景。
▸ 风险提示
打包时会执行任意 JS,可能引入不安全代码或泄露信息。
这个 Skill 做什么
说明在打包时执行 JS 并将结果内联的 Bun 宏用法。
Bun 的宏能在打包时执行 JavaScript 并把结果内联到输出文件里,适合做编译期代码生成、内嵌文件或把环境变量在构建阶段就确定下来。用它可以把运行时开销提前到构建时,减少运行时逻辑并加快启动速度。特点是把动态内容变成静态产物,方便性能优化和减小运行时依赖。
▸ 展开 SKILL.md 英文原文
Evaluate JavaScript at bundle time and inline results. Use when optimizing compile-time code generation, embedding files, inlining environment variables, or executing code during the bundling process.
180
Stars
28
Forks
40
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/bun/skills/bun-macros/SKILL.md或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/bun/skills/bun-macros/SKILL.md"SKILL.MD 节选查看完整文件 ↗
# Bun Macros
Bun macros run JavaScript at bundle time and inline the results into the output.
## Quick Start
```typescript
// src/config.ts (macro file)
export function getVersion() {
return "1.0.0";
}
export function getBuildTime() {
return new Date().toISOString();
}
// src/index.ts (consumer)
import { getVersion, getBuildTime } from "./config" with { type: "macro" };
// At bundle time, these become:
const version = "1.0.0";
const buildTime = "2024-01-15T12:00:00.000Z";
```
## Macro Syntax
```typescript
// Import with macro attribute
import { fn } from "./macro-file" with { type: "macro" };
// Call the macro (evaluated at build time)
const result = fn();
```
## Common Use Casvia SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有