I am maintaining an NPM package (lets say it as package-A
) that relies on an another NPM package(package-B
) to function. Therefore, I am in need to add that package as peer-dependency into the package.json
, so that npm and the user can be sure that everything is correct.
The problem is, package-B
use pre-release versioning. I am well aware that it uses semver wrong, but I am not able to change the company policy, yet. Meanwhile enforcing to use proper versioning will happen. The semantic is like this:
So basically, the patch version increases when there is another production release.
Case: Because of the versioning, I need to include every package except major one to match as peer dependency, together with pre-releases.
The need is basically ^1.0.0
with everything including pre-releases that happens to have 1
as major as peer dependency
^1.0.0
-> Does not include pre-releases^1.0.0 || >=1.0.0-beta.X
-> Does not include e.g. 1.0.1-beta.1
*
-> Does not include pre-releases^1.0.0 || >=1.X.X-beta.X
-> Does not work.On semver, there is a parameter called --include-prerelease
which I think does what I need, specific to semver commands obviously.
react
package on NPM has similar versioning system with proper usage of pre-release. E.g. it has 16.0.0
, 16.0.0-alpha.1
and 16.6.0-alpha.0
. I basically need to include all this on a single range.
Disclaimer: Minor version is changed when there is a breaking change going on. Yet again, I am well aware that this versioning is not up to semver regulations and advising it unfortunately will not solve the problem at hand.
https://classic.yarnpkg.com/en/docs/dependency-versions#toc-pre-release-tags
If a comparator includes a version with a pre-release tag it will only match against versions that have the same
major.minor.patch
version.
You can only include pre-releases of specific versions.
>=1.0.0-beta
includes 1.0.0-beta.X
, but not 1.0.1-beta.X
You can play around with the semver pre-release ranges on https://semver.npmjs.com/
Lookup the package @artsy/reaction
they have bunch of pre-releases