Bun monorepo workflows (Cloudflare Workers SaaS kit)
This repo is currently pnpm-based, but Bun can act as the package manager for the monorepo. This skill covers (1) day-to-day Bun equivalents for pnpm workflows and (2) a safe pnpm → Bun migration checklist.
Quick commands (Bun)
- •Install all deps:
bun install - •CI install (frozen lockfile):
bun ci(equivalent tobun install --frozen-lockfile) - •Run a root script:
bun run <script> - •Run a workspace script (common patterns):
- •By filter:
bun --filter <workspace-name-or-glob> run <script> - •By path filter:
bun --filter ./apps/user-application run build
- •By filter:
- •Add deps:
- •Prod:
bun add <pkg> - •Dev:
bun add -d <pkg>
- •Prod:
- •List deps:
bun pm ls(orbun list) - •Lockfile / migration utilities:
bun pm migrate
Filtering and “package scoping”
Bun’s primary mechanism is --filter.
Examples:
- •Install everything except one workspace:
bun install --filter '!data-service' - •Install only one workspace (by path):
bun install --filter './apps/user-application' - •Run TS typecheck in just UI:
bun --filter @workspace/ui run tsc
Notes:
- •Bun supports workspace globs and negative patterns.
- •Prefer filtering by path when package names aren’t unique or you’re unsure of the workspace name.
Cloudflare/Wrangler note (important)
This repo uses Cloudflare Workers tooling (Wrangler, workerd). Bun is fine as a package manager, but Wrangler is not universally supported when executed via Bun’s runtime.
Practical guidance:
- •Prefer
bun run <script>without forcing Bun’s runtime. - •Bun’s
bun runrespects#!/usr/bin/env nodeshebangs by default, so CLIs likewranglerusually run on your system Node. - •If you hit Wrangler weirdness under Bun, run Wrangler directly with Node (or via the existing pnpm workflow) rather than forcing
bun --bun.
pnpm → Bun migration checklist (safe)
Bun will automatically migrate pnpm-lock.yaml to bun.lock when you run bun install and no bun.lock exists yet.
Recommended sequence:
- •Clean install state
- •Remove
node_modules(and workspace node_modules if present).
- •Remove
- •Generate Bun lockfile
- •Run
bun installat repo root. - •Verify it produced
bun.lock.
- •Run
- •Verify key workflows still work
- •Run the same “known good” scripts you currently use for CI/dev (build + typecheck for each app/package).
- •Pay special attention to:
- •
packages/data-opsbuild - •app typechecks
- •Wrangler/dev scripts
- •
- •Commit lockfile + any required config changes
- •Bun docs recommend committing
bun.lock.
- •Bun docs recommend committing
- •Optional: remove pnpm artifacts after verification
- •After you’re confident, remove
pnpm-lock.yamlandpnpm-workspace.yaml. - •If you keep pnpm around temporarily, do not mix installs (avoid generating both lockfiles in CI).
- •After you’re confident, remove
Bun-specific notes that matter during migration:
- •Bun v1.2+ defaults to the text lockfile
bun.lock(older versions usedbun.lockb). - •Bun does not run dependency lifecycle scripts by default; if a dependency requires scripts, add it to
trustedDependenciesin the relevantpackage.json, then reinstall.
What to update in repo configs (typical)
When the actual migration happens (if/when you switch the repo’s canonical PM):
- •Root
package.json:- •Consider setting
packageManagertobun@<version>to signal the expected tool. - •Ensure
workspacesconfig exists (Bun supportsworkspacesand will migrate frompnpm-workspace.yamlautomatically).
- •Consider setting
- •CI:
- •Replace
pnpm installwithbun ci. - •Use
oven-sh/setup-bunGitHub Action.
- •Replace
References
- •Command mapping + “pnpm filter” equivalents: see
.github/skills/bun-monorepo-workflows/references/command-mapping.md - •Migration gotchas + verification checklist: see
.github/skills/bun-monorepo-workflows/references/migration-notes.md