Nx release only replaces local dependency protocol with actual version for bumped packages #29454
Description
Current Behavior
Based on the documentation here, I have configured a workspace containing 3 libraries. lib-a
, lib-b
and lib-c
. lib-c
depends on both lib-a
and lib-b
using file protocol to link local dependencies. The tsc executor has been configured to write build output to the centralized dist
directory in the root of the repo. Nx release has been configured with a custom packageRoot
for both the version
generator and the nx-release-publish
executor.
lib-c/package.json
{
"name": "@thdk/lib-c",
"version": "0.3.0",
"dependencies": {
"@thdk/lib-a": "file:../lib-a",
"@thdk/lib-b": "file:../lib-b",
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"files": [
"src",
"!**/*.tsbuildinfo"
],
"nx": {
"sourceRoot": "libs/lib-c/src",
"projectType": "library",
"name": "lib-c"
}
}
Now, when we make a change to lib-a
and run nx release
only the version for lib-a
is resolved. The untouched lib-b
remains referenced using the file protocol. Which causes the publish step of nx release
to fail.
Expected Behavior
nx release version
should resolve either the current or bumped version for:
- all directly touched projects (bumped version)
- all projected on which the touched projects depend (the current version)
So that the generated package.json
for touched projects never contains local dependency protocols.
GitHub Repo
Steps to Reproduce
create workspace
npx create-nx-workspace nx-release-cc-versioning-different-project-root
navigate to new workspace
cd nx-release-cc-versioning-different-project-root
install nx and dependencies
npm install
generate libs
npx nx g @nx/js:lib --directory libs/lib-a --name lib-a --publishable --import-path @thdk/lib-a
npx nx g @nx/js:lib --directory libs/lib-b --name lib-b --publishable --import-path @thdk/lib-b
npx nx g @nx/js:lib --directory libs/lib-c --name lib-c --publishable --import-path @thdk/lib-c
add @thdk/lib-a
and @thdk/lib-b
as dependencies for @thdk/lib-c
.
npm install -w @thdk/lib-c @thdk/lib-a @thdk/lib-b --save-exact
configure nx release in nx.json
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": ["default"],
"sharedGlobals": []
},
"plugins": [
{
"plugin": "@nx/js/typescript",
"options": {
"typecheck": {
"targetName": "typecheck"
},
"build": {
"targetName": "build",
"configName": "tsconfig.lib.json"
}
}
}
],
"release": {
"projects": ["tag:publishable"],
"releaseTagPattern": "{projectName}@{version}",
"projectsRelationship": "independent",
"version": {
"preVersionCommand": "npx nx run-many --target build --exclude='*,!tag:publishable'",
"generatorOptions": {
"packageRoot": "dist/{projectRoot}",
"specifierSource": "conventional-commits",
"currentVersionResolver": "git-tag",
"updateDependents": "auto",
"fallbackCurrentVersionResolver": "disk"
}
},
"changelog": {
"automaticFromRef": true,
"projectChangelogs": {
"renderOptions": {
"authors": true,
"commitReferences": true,
"versionTitleDate": true
}
}
},
"git": {
"commit": true,
"tag": true
}
},
"targetDefaults": {
"nx-release-publish": {
"options": {
"tag": "latest",
"packageRoot": "dist/{projectRoot}"
}
}
}
}
start local verdaccio registry
npx nx local-registry
add a file to lib-c
touch libs/lib-c/src/feature-1.txt
git add lib/lib-c/src/feature-2.txt
git commit -m 'feat: add feature 1'
release
npx nx release # will fail because generated (and versioned) `package.json` for `lib-c` will contain local dependency protocals to reference `lib-a` and `lib-b`.
add a file to lib-a
touch libs/lib-a/src/feature-1.txt
git add lib/lib-a/src/feature-2.txt
git commit -m 'feat(lib-a): add feature 1'
release
npx nx release # still fails, but now the version for `lib-a` was actually resolved in the generated package.json file for `lib-c` but the untouched `lib-b` is still reference using the file protocal.
Nx Report
Node : 22.2.0
OS : darwin-arm64
Native Target : aarch64-macos
npm : 10.8.0
nx : 20.2.2
@nx/js : 20.2.2
@nx/workspace : 20.2.2
@nx/devkit : 20.2.2
typescript : 5.6.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
Failure Logs
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
No response