Skip to content
This documentation is for v14, the docs for v13 are archived.

Same Minor

Loosen requirements to only ensure that the MAJOR.MINOR.x version number should match for all members of this group, allowing different patch versions. The only semver ranges allowed are exact and ~ as others will allow versions to be installed outside of this range.

Consider whether you need this behaviour because it will result in another copy of the same dependency being installed for every patch version number which is not the same. Usually we're trying to reduce the number of variables in our system and increase confidence, so most people won't need this.

One use case where a Same Minor group can help is when using a dependency group to alias multiple related packages such as @aws-sdk/** into one, each package in the set may not have identical version numbers, but they should fall within the same minor.

Configuration

policy Required

Set the policy to "sameMinor" to enable this behaviour for a Version Group.

{
"versionGroups": [
{
"dependencies": ["react", "react-dom"],
"policy": "sameMinor"
}
]
}

dependencies Optional

  • An array of names of dependencies you've installed or otherwise reference in your package.json files.
  • If omitted, the default behaviour is to match every dependency.
  • The strings can be any combination of exact matches or glob patterns:
// match any dependency
dependencies: ["**"]
// match all dependencies with a certain scope
dependencies: ["@aws-sdk/**"]
// match specific dependencies by name
dependencies: ["react", "react-dom"]
{
"name": "HERE",
"dependencies": { "HERE": "0.0.0" },
"devDependencies": { "HERE": "0.0.0" },
"overrides": { "HERE": "0.0.0" },
"peerDependencies": { "HERE": "0.0.0" },
"pnpm": { "overrides": { "HERE": "0.0.0" } },
"resolutions": { "HERE": "0.0.0" }
}

dependencyTypes Optional

A "dependency type" refers to the path/location/nested property of package.json files where dependencies can be found.

  • When set, only dependencies present in the named locations will be assigned to this group.
  • If omitted, the default behaviour is to match dependencies everywhere they are found.
  • Negated types are also supported, so a value of ["!dev", "!prod"] would assign everything except dependencies and devDependencies to this group.

See the Dependency Types guide for the list of possible values.

specifierTypes Optional

  • When set, only dependencies whose version specifier matches the given specifier types will be assigned to this group.
  • If omitted, the default behaviour is to match all dependencies.
  • Negated types are also supported, so a value of ["!latest", "!file"] would assign everything except specifiers of the format * and file:path/to/package.tgz to this group.

label Optional

  • A short name or description displayed as a header in syncpack's output.
  • If a label is not set then eg. "Version Group 3" will be used instead.

preferVersion Optional

When set, determines how to resolve versions when instances differ in their MAJOR.MINOR (while sharing the same MAJOR version).

{
"versionGroups": [
{
"dependencies": ["react", "react-dom"],
"policy": "sameMinor",
"preferVersion": "highestSemver"
}
]
}

Possible values

The default status for instances that differ in MAJOR.MINOR is SameMinorMismatch, which is not auto-fixable, since syncpack can't know which minor versions are safe to change without your guidance.

  • "highestSemver" - Updates instances to use the highest MAJOR.MINOR version found in the group
  • "lowestSemver" - Updates instances to use the lowest MAJOR.MINOR version found in the group

packages Optional

  • An array of strings which should match the name properties of your package.json files.
  • If omitted, the default behaviour is to match every package.
  • Negated types are also supported, so a value of ["!my-client", "!my-server"] would assign everything except the packages my-client and my-server to this group.
  • The strings can be any combination of exact matches or glob patterns:
// ✅ match any package name
packages: ["**"]
// ✅ match any package name with this scope
packages: ["@my-repo/**"]
// ✅ match specific packages by name
packages: ["my-server", "my-client"]
// ✅ match all packages except negated ones
packages: ["!my-server", "!@my-repo/**]
// ❌ no mixing of specific and negated packages
packages: ["my-client", "!@my-repo/**"]
// ❌ not file system paths, name properties of package.json files
packages: ["packages/my-client"]
// ❌ not file system globs, name properties of package.json files
packages: ["packages/**"]
{
"name": "HERE",
"version": "1.0.2"
}

Status Codes

These are all the issues that a Same Minor Version Group can find:

Valid

Fixable

Unfixable