synopkg
Version:
Consistent dependency versions in large JavaScript Monorepos
43 lines (35 loc) • 1.38 kB
text/mdx
---
title: Ensure that semver ranges for a dependency all match each other
---
Add a [Same Range Version Group](VERSION_GROUP_SAME_RANGE) which allows local packages installed in `devDependencies` or `peerDependencies` to use different semver ranges, as long as they all match the local package version.
- An optional **label** can be added to document the rule.
- The **dependencies** array defines the names of the dependencies we want to target.
- **dependencyTypes** results in these dependencies only being targeted by this group when they are located in `devDependencies` or `peerDependencies`.
- The **policy** of **sameRange** states that these dependencies are considered valid if every range matches the others.
```json title=".synopkgrc.json"
{
"versionGroups": [
{
"label": "Ensure semver ranges for locally developed packages satisfy the local version",
"dependencies": [
"@your-repo/node-client-plugin-retry",
"@your-repo/node-client",
"dashboard-ui"
],
"dependencyTypes": ["dev", "peer"],
"policy": "sameRange"
}
]
}
```
:::tip
The above example can be shortened: The `$LOCAL` keyword is a helper to avoid writing out the names of every local package.
```diff
"dependencies": [
+ "$LOCAL"
- "@your-repo/node-client-plugin-retry",
- "@your-repo/node-client",
- "dashboard-ui"
],
```
:::