Upgrading Dependencies
The BE Monorepo follows a strict exact-version policy for dependencies to ensure reproducible builds and prevent unexpected breaking changes.Exact Version Policy
All dependencies must use exact versions (no^ or ~ prefixes).
- Reproducibility: Same dependencies across all environments
- Predictability: No surprise updates from semver ranges
- Control: Explicit decision for every version change
Upgrade Workflow
Follow this workflow when upgrading dependencies:1. Check for Updates
Run the dependency bump command:npm-check-updates to check for outdated dependencies across:
- Production dependencies (
dependencies) - Development dependencies (
devDependencies) - Optional dependencies (
optionalDependencies) - Package manager version (
packageManager) - Peer dependencies (
peerDependencies)
- Checks all nested workspaces (
--deep) - Updates all dependency types (
--dep prod,dev,optional,packageManager,peer) - Writes updates to
package.jsonfiles (-u) - Excludes certain packages (
-x @babel*,tamagui)
2. Install Updates
After reviewing the proposed changes, install the updated dependencies:bun.lock with the new dependency versions.
3. Run Tests
Verify that the updates don’t break functionality:4. Build (Optional)
If you use Node.js runtime, verify the build succeeds:5. Lint and Type Check
Run linting and type checking to catch any issues:6. Create a Changeset
Document the dependency updates using changesets:7. Version the Changeset
Update package versions based on the changeset:- Package versions in
package.json CHANGELOG.mdfiles- Consumes the changeset files
Excluded Packages
Some packages are excluded from automatic updates:@babel*: Babel packages (if used)tamagui: UI library (if used)
Full Workflow Example
Complete example of upgrading dependencies:Common Issues
Breaking Changes
If a dependency introduces breaking changes:- Read the package’s
CHANGELOG.mdor release notes - Update your code to match the new API
- Run tests to verify fixes
- Document breaking changes in your changeset
Type Errors
New dependency versions may introduce type errors:- Run
bun lint-typecheckto identify issues - Update type definitions or code as needed
- Consider updating
@types/*packages if using TypeScript
Failed Tests
If tests fail after updates:- Review test output for specific failures
- Check if the dependency changed its behavior
- Update tests or code to match new behavior
- Consider rolling back the problematic update
Lock File Conflicts
If you encounterbun.lock conflicts:
Automated Updates
Consider setting up automated dependency updates using:- Dependabot: GitHub’s automated dependency updates
- Renovate: Configurable dependency update bot
- Create pull requests for updates
- Group updates by type (major, minor, patch)
- Auto-merge patch updates after tests pass
Best Practices
- Update regularly: Don’t let dependencies get too outdated
- Update incrementally: Update a few packages at a time
- Test thoroughly: Always run the full test suite
- Read changelogs: Understand what changed before updating
- Document changes: Use changesets to track dependency updates
- Review PRs carefully: Check for breaking changes in automated PRs
