semver
semver copied to clipboard
[Get Somthing Trouble] seems related to --allowEmptyRelease=false
There is a common situation: in a normal Monorepo, suppose there is a package named lib
, as it says lib is the common dependency of other upper packages, says we have the upper package A
and the upper package B
, A
and B
both depend on lib
. Then we want:
- For every change that happened on
lib
,A
andB
should bump their version cause their dependencies list is updated. - Instead of all packages having the same version, every package should have its own version.
For these needs, all the packages in the Monorepo should enable the trackDeps
flag in their project.json
for NX, and correctly set the version target's dependsOn
for NX, as the doc(Tracking dependencies) instructed. When lib
's change comes, we can easily get this feature by using the affected
command prepared by NX. Ideally, none of the packages will be versioned multiple times.
Here the issue comes:
When there is a change on the package A
, then we run nx affected
to automatically version packages. Package A's change will be detected, it says there is only one version target that should be executed. But cause we set the version target depending on package A's dependencies' version target to be executed first, so in fact, the lib
's version target will be executed once before package A's version target is executed.
Although there are no changes happening on the lib
package, the version target's execution can not be canceled, and the --allowEmptyRelease
is not working for that case. The result is lib
will always generate an unnecessary empty release commit, at the same time, the lib
package is so basic that not only package A and B depend on it, all of the packages depend on lib
will be affected by this unnecessary empty release commit which is unacceptable.
I sincerely apologize if this seems foolish, but it might be due to my misunderstanding or an incorrect action on my part. I would greatly appreciate your guidance and advice.
Hello,
Thank you for raising this issue. We are currently working on semver v3, which aims to address these types of problems. We are committed to improving the reliability and usability of using semver in a workspace where libs depend on each other.
In the meantime, I would suggest not composing --allowEmptyRelease and --trackDeps together.
@edbzn Thanks for your reply! Hope semver v3 is going great. Actually, I use allowEmptyRelease=false
with trackDeps=true
together. The issue I described can be summarized to:
Having A as a dep of B, when B changes, NX's target dependencies calculating the A's version command should be executed before executing the B's version command. The allowEmptyRelease: false
configured for A is not work as expected. The expected behavior is not to generate any version change for A cause there is no change for it. The actual result is A will have a new empty release although allowEmptyRelease: false
is set for it.
Hope the information I have provided will help you locate the problem. ♥