pnpm add -D @aklinker1/buildc
bun add -D @aklinker1/buildc- ⚡️ Only rebuilds packages when their files change
- 🔗 Builds workspace dependencies in the correct order
- 🔒 Safe to run in parallel, only one process builds at a time
- 🛠️ Zero config, with per-package overrides
- 🦀 Ships as a native binary
Supported workspaces
- ✅ PNPM
- ✅ Bun
Note
The native binary is installed by a postinstall script. If your package manager blocks lifecycle scripts, allow them for @aklinker1/buildc.
Prefix any package-specific build commands you want to cache with buildc -- :
// packages/example/package.json
-"build": "tsdown",
+"build": "buildc -- tsdown",Now when you run the build script for that package, it will only rebuild the package if a file has changed.
If your package depends on one or more other packages in the monorepo, buildc detects that and runs those packages' build scripts in the correct order.
To ensure a package's dependencies are built before running a command, use buildc deps && :
-"test": "vitest",
+"test": "buildc deps && vitest",Only one buildc process builds packages at a time, so it's safe to run multiple buildc commands in parallel. Commands after buildc deps && run after the lock is released, so they run in parallel too.
buildc all: Build all the packages in your monorepo. Can be run from any directory inside the monorepo.buildc graph: Print a dependency graph showing which packages depend on others.buildc clean: Delete all build caches.buildc prune: Delete old build caches, keeping current ones. Useful for keeping CI caches small.
Set BUILDC_SKIP=true to skip building packages when running buildc or buildc deps. buildc -- <cmd> still runs <cmd>, but it doesn't build dependencies or check the cache first.
This is useful in CI: once you've run buildc all, other commands don't need to build anything:
buildc all
BUILDC_SKIP=true bun run testSet DEBUG=buildc to enable debug logs:
DEBUG=buildc bun run buildEach package.json can have a buildc field where you can configure options. Listed below are the defaults:
{ // ..., "buildc": { // Set to false to disable the cache-checking behavior for this package "cache": true, // The directory where your build is output to "outDir": "dist", // List of glob patterns to include when checking if the package needs rebuilt "include": ["src/**/*", "package.json", "*.config.ts"], // List of glob patterns to ignore when checking if the package needs rebuilt "exclude": ["**/__tests__/**", "**/__mocks__/**", "**/*.test.*", "**/e2e/**", "**/dist/**", "**/.output/**"], }, }