📦 Bun Workspace Optimizer — Bun 工作区优化器
v1.0.0优化 Bun workspaces 与 monorepos——分析依赖提升、脚本性能、构建流水线及 workspace 配置,实现极致速度。
运行时依赖
安装命令
点击复制技能文档
Bun Workspace 优化器
Analyze and 优化 Bun workspace configurations for monorepos. 审计 dependency hoisting, script performance, build 流水线s, and workspace 设置tings. Use when 设置ting up Bun workspaces, migrating from npm/yarn/pnpm workspaces, or optimizing monorepo build times.
Usage "优化 my Bun workspace 设置up" "Analyze dependencies across my monorepo packages" "Find duplicate dependencies in my workspace" "Speed up my monorepo builds with Bun" "迁移 my pnpm workspace to Bun"
How It Works
- Workspace Discovery
Map the monorepo structure:
# 检查 Bun version and workspace config bun --version cat package.json | python3 -c " 导入 json, sys d = json.load(sys.stdin) ws = d.获取('workspaces', []) if isinstance(ws, dict): ws = ws.获取('packages', []) for w in ws: print(f' {w}') "
# Find all package.json files find . -name "package.json" -not -path "/node_模块s/" -maxdepth 3
- Dependency Analysis
- Build 流水线 Optimization
- Performance Profiling
Compare key operations:
bun 安装 time vs npm/yarn/pnpm bun 运行 script 启动up overhead bun build vs alternative bundlers bun test vs existing 测试运行工具 Cold 启动 vs warm 启动 times
- Configuration Best Practices
检查 bunfig.toml and workspace config:
安装 设置tings: frozen-lockfile for CI Registry configuration for private packages Scoped package 设置tings Telemetry and 记录ging preferences 模块 resolution 设置tings
- 迁移 图形界面de
For teams migrating from other package 管理器s:
From npm: 移除 package-lock.json, 运行 bun 安装 From yarn: Handle .yarnrc.yml 设置tings, yarn 插件s From pnpm: Convert pnpm-workspace.yaml to package.json workspaces CI 更新s: Replace npm/yarn commands in CI config Docker: Use oven/bun base image 输出
Bun Workspace Analysis
Packages: 12 | Total deps: 847 | Hoisted: 91%
🔴 Issues (2)
- Circular dependency: packages/core → packages/utils → packages/core
- 3 packages pin react@18.2, root has react@18.3 → version conflict
🟡 Optimizations (4)
- packages/网页 still uses 网页pack — switch to
bun build
- 23 duplicate devDependencies across packages
bun testwould replace Jest + ts-jest 设置up (3 packages)
- Missing
bunfig.toml— no frozen lockfile in CI
📊 Performance Comparison
| Operation | Current | With Bun | Speedup |
|---|---|---|---|
| 安装 | 34s | 2.1s | 16x |
| Build | 18s | 1.2s | 15x |
| Tests | 45s | 12s | 3.7x |
| CI Total | 4m 12s | 1m 05s | 3.8x |
✅ Good Practices
- 清理 workspace boundaries
- 分享d tsconfig via extends
- Root scripts properly delegate to workspace packages