`nx release`: regressions with independent projects relationship
Current Behavior
Since v22 I'm facing a lot of regressions during nx release of independent projects.
Consider the following:
projects/
- libA
- fileA.ts
- package.json (version 1.0.0)
- libB
- package.json (version 1.0.0, dep: libA)
nx.json (projectsRelationship: independent)
README.mdRegression 1
- Make changes to
projects/libA/fileA.ts - Commit the changes as
feat(A): changes - Run
nx release version --projects=libA --dry-run - Result version for libA will be
1.0.1(instead of1.1.0)
This is due to:
https://github.com/nrwl/nx/blob/a15881db1a12cc2e2dd000f7aa576f4606aa410a/packages/nx/src/command-line/release/utils/semver.ts#L43-L48
There is now a config.useCommitScope that is true by default.
And isProjectScopedCommit is obviously false because the scope is A (not libA).
This a clearly a breaking change in v22 and I might be wrong but there is no info about it in the changelog.
Luckily there were this issue and PR to give a hint: https://github.com/nrwl/nx/issues/33686 https://github.com/nrwl/nx/pull/33382
> Fix
Use nx.json#release.conventionalCommits.useCommitScope: false.
But having this config set to true by default doesn't seems to be the right idea to me.
Regression 2
- Make changes to
README.md - Commit the changes as
chore: update readme - Run
nx release version --dry-run - Both
libAandlibBwill have a version bump
This is also a breaking change in v22. Modifying non project files should not impact projects during the release.
Non project files were filtered out before v22, but this part was removed: https://github.com/nrwl/nx/pull/32915/files#diff-8eb063679cb409022dbf351f7017d1b49fd1e643ac0150b6d0669a475bbc5c65L364-L366
> Temporary fix
Filtering out non project files as before indeed fix the issue.
Now both libA and libB do not trigger a release.
// Convert affectedFiles to FileChange[] format with proper diff computation
let touchedFiles = (0, file_utils_1.calculateFileChanges)(commit.affectedFiles, {
base: `${commit.shortHash}^`,
head: commit.shortHash,
});
+ const { fileMap } = await createFileMapUsingProjectGraph(projectGraph);
+ touchedFiles = touchedFiles.filter(tf => !fileMap.nonProjectFiles.some(npf => npf.file === tf.file));
// Use the same affected detection logic as `nx affected`
const affectedGraph = await (0, affected_project_graph_1.filterAffected)(projectGraph, touchedFiles);Regression 3
Since v22 the way relevant commits are calculated for a project is based on nx affected instead of the touched files for that commit. There might be good reasons for that change but it clearly brings regressions to independent projects.
- Make changes to
projects/libA/fileA.ts - Commit the changes as
feat(A): changes - Run
nx release version --projects=libB --dry-run - Result version for libB will be
1.1.0(instead of1.0.1)
The only changes to libB should be a patch: libA had a version bump so libB dep needs to be updated.
This is due to the fact that every commit is now relevant to any projects - they are all affected in the graph but no distinction are made about the actual touched files in the commit.
Because of this:
https://github.com/nrwl/nx/blob/75f36edb8f5dc0af2aaaeb40b123471ccff159ac/packages/nx/src/command-line/release/utils/shared.ts#L476-L480
it always fallback to the else close and the feat commit that was made to libA is now also relevant to libB and gives a minor bump instead of a patch one.
Expected Behavior
I expect everything to work as prior to v22.
Steps to Reproduce
- Checkout https://github.com/DSI-HUG/ngx-components
- Run
npm install
Regression 1
- Run
npx nx release --dry-run --projects=@hug/ngx-date-picker - You can see in the changelog that new features were detected but the new version is
21.0.1(instead of21.1.0)
Using useCommitScope: false fix the issue.
Regression 2
- Run
npx nx release --dry-run --projects=@hug/ngx-message-box-dialog - You can see in the changelog that
This was a version bump only ..., there were no code changes.
This release is due to non project files triggering it, forcing every packages in the repo to be wrongly released every time.
Filtering out the non project files as described in the current behavior section, do not triggers a release as expected.
Regression 3
- Define
useCommitScope: falsein the config - Run
npx nx release --dry-run - Have a look at the changelog of
search-container
You can see that a release was triggered because of a dep bump but the new version of that release should be a patch not a minor.
Nx Report
Node : 22.20.0
OS : darwin-x64
Native Target : x86_64-macos
npm : 11.8.0
daemon : Available
nx (global) : 22.4.1
nx : 22.4.1
@nx/js : 22.4.1
@nx/workspace : 22.4.1
@nx/devkit : 22.4.1
typescript : 5.9.3
---------------------------------------
Cache Usage: 0.00 B / 93.15 GBOperating System
- macOS
- Linux
- Windows
- Other (Please specify)
Source: nrwl/nx