skills/bun-pm-catalogs/SKILL.md
Share common dependency versions across multiple packages in a monorepo
npx skillsauth add jarle/bun-skills Bun CatalogsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Share common dependency versions across multiple packages in a monorepo
Catalogs in Bun provide a straightforward way to share common dependency versions across multiple packages in a monorepo. Rather than specifying the same versions repeatedly in each workspace package, you define them once in the root package.json and reference them consistently throughout your project.
Unlike traditional dependency management where each workspace package needs to independently specify versions, catalogs let you:
catalog: protocolThis is especially useful in large monorepos where dozens of packages need to use the same version of key dependencies.
Consider a monorepo with the following structure:
my-monorepo/
├── package.json
├── bun.lock
└── packages/
├── app/
│ └── package.json
├── ui/
│ └── package.json
└── utils/
└── package.json
In your root-level package.json, add a catalog or catalogs field within the workspaces object:
{
"name": "my-monorepo",
"workspaces": {
"packages": ["packages/*"],
"catalog": {
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"catalogs": {
"testing": {
"jest": "30.0.0",
"testing-library": "14.0.0"
}
}
}
}
If you put catalog or catalogs at the top level of the package.json file, that will work too.
In your workspace packages, use the catalog: protocol to reference versions:
{
"name": "app",
"dependencies": {
"react": "catalog:",
"react-dom": "catalog:",
"jest": "catalog:testing"
}
}
{
"name": "ui",
"dependencies": {
"react": "catalog:",
"react-dom": "catalog:"
},
"devDependencies": {
"jest": "catalog:testing",
"testing-library": "catalog:testing"
}
}
Run bun install to install all dependencies according to the catalog versions.
Bun supports two ways to define catalogs:
catalog (singular): A single default catalog for commonly used dependencies
"catalog": {
"react": "^19.0.0",
"react-dom": "^19.0.0"
}
Reference with simply catalog::
"dependencies": {
"react": "catalog:"
}
catalogs (plural): Multiple named catalogs for grouping dependencies
"catalogs": {
"testing": {
"jest": "30.0.0"
},
"ui": {
"tailwind": "4.0.0"
}
}
Reference with catalog:<name>:
"dependencies": {
"jest": "catalog:testing",
"tailwind": "catalog:ui"
}
Here's a more comprehensive example for a React application:
Root package.json
{
"name": "react-monorepo",
"workspaces": {
"packages": ["packages/*"],
"catalog": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^6.15.0"
},
"catalogs": {
"build": {
"webpack": "5.88.2",
"babel": "7.22.10"
},
"testing": {
"jest": "29.6.2",
"react-testing-library": "14.0.0"
}
}
},
"devDependencies": {
"typescript": "5.1.6"
}
}
{
"name": "app",
"dependencies": {
"react": "catalog:",
"react-dom": "catalog:",
"react-router-dom": "catalog:",
"@monorepo/ui": "workspace:*",
"@monorepo/utils": "workspace:*"
},
"devDependencies": {
"webpack": "catalog:build",
"babel": "catalog:build",
"jest": "catalog:testing",
"react-testing-library": "catalog:testing"
}
}
{
"name": "@monorepo/ui",
"dependencies": {
"react": "catalog:",
"react-dom": "catalog:"
},
"devDependencies": {
"jest": "catalog:testing",
"react-testing-library": "catalog:testing"
}
}
{
"name": "@monorepo/utils",
"dependencies": {
"react": "catalog:"
},
"devDependencies": {
"jest": "catalog:testing"
}
}
To update versions across all packages, simply change the version in the root package.json:
"catalog": {
"react": "^19.1.0", // Updated from ^19.0.0
"react-dom": "^19.1.0" // Updated from ^19.0.0
}
Then run bun install to update all packages.
Bun's lockfile tracks catalog versions, making it easy to ensure consistent installations across different environments. The lockfile includes:
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "react-monorepo",
},
"packages/app": {
"name": "app",
"dependencies": {
"react": "catalog:",
"react-dom": "catalog:",
...
},
},
...
},
"catalog": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
...
},
"catalogs": {
"build": {
"webpack": "5.88.2",
...
},
...
},
"packages": {
...
}
}
catalog or one of the named catalogsbun installBun's catalog system provides a powerful yet simple way to maintain consistency across your monorepo without introducing additional complexity to your workflow.
When you run bun publish or bun pm pack, Bun automatically replaces
catalog: references in your package.json with the resolved version numbers.
The published package includes regular semver strings and no longer depends on
your catalog definitions.
development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling