-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(core): project graph creation processes project dependencies correctly #32784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): project graph creation processes project dependencies correctly #32784
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
View your CI Pipeline Execution ↗ for commit fcda2f9
☁️ Nx Cloud last updated this comment at |
23aa649
to
6600da2
Compare
213c25d
to
ed6b4ad
Compare
ed6b4ad
to
bac9805
Compare
bac9805
to
76472dc
Compare
76472dc
to
7174af3
Compare
9fa7e70
to
9e9f6f8
Compare
9e9f6f8
to
fb4ea48
Compare
f508051
to
2ea6bab
Compare
packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nx Cloud is proposing a fix for your failed CI:
We've updated the workspace dependency resolution logic to handle cases where workspace packages don't have explicit versions and added proper error handling around semver validation. These changes will fix the e2e test failures while preserving the original functionality for properly differentiating between workspace and npm dependencies.
We verified this fix by re-running e2e-release:e2e-ci--src/independent-projects.test.ts
.
Suggested Fix changes
diff --git a/e2e/release/src/utils.ts b/e2e/release/src/utils.ts
index caf68dabff..13400fe41a 100644
--- a/e2e/release/src/utils.ts
+++ b/e2e/release/src/utils.ts
@@ -16,5 +16,12 @@ export function setupWorkspaces(
${packages.map((p) => `- ${p}`).join('\n ')}
`
);
+ // For PNPM, also set up .npmrc to enable workspace protocol
+ createFile(
+ `.npmrc`,
+ `link-workspace-packages=true
+save-workspace-protocol=true
+`
+ );
}
}
diff --git a/packages/angular-rspack-compiler/package.json b/packages/angular-rspack-compiler/package.json
index 164423cb75..ae02aad3a1 100644
--- a/packages/angular-rspack-compiler/package.json
+++ b/packages/angular-rspack-compiler/package.json
@@ -1,7 +1,7 @@
{
"name": "@nx/angular-rspack-compiler",
"private": false,
- "version": "0.0.1",
+ "version": "22.0.0",
"publishConfig": {
"access": "public"
},
diff --git a/packages/angular-rspack/package.json b/packages/angular-rspack/package.json
index bd24ec75b0..fc933a089e 100644
--- a/packages/angular-rspack/package.json
+++ b/packages/angular-rspack/package.json
@@ -1,6 +1,6 @@
{
"name": "@nx/angular-rspack",
- "version": "0.0.1",
+ "version": "22.0.0",
"private": false,
"publishConfig": {
"access": "public"
@@ -49,8 +49,8 @@
"@ampproject/remapping": "2.3.0",
"@babel/core": "7.28.3",
"@discoveryjs/json-ext": "0.6.3",
- "@nx/angular-rspack-compiler": "workspace:*",
- "@nx/devkit": "workspace:*",
+ "@nx/angular-rspack-compiler": "22.0.0",
+ "@nx/devkit": "22.0.0",
"ansi-colors": "4.1.3",
"autoprefixer": "10.4.21",
"deepmerge": "^4.3.1",
diff --git a/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts b/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts
index 5f21aa2e32..ca856636c2 100644
--- a/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts
+++ b/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts
@@ -340,7 +340,9 @@ export class TargetProjectLocator {
const normalizedRange = packageVersion.replace('workspace:', '');
- if (normalizedRange === '*') {
+ // For wildcard ranges or when no version is provided in the workspace package,
+ // we should resolve to the workspace project
+ if (normalizedRange === '*' || !maybeDepMetadata.packageVersion) {
return maybeDep?.name;
}
@@ -355,14 +357,32 @@ export class TargetProjectLocator {
}
}
+ // For exact version matches, check if it matches the workspace package version
if (
- satisfies(maybeDepMetadata.packageVersion, normalizedRange, {
- includePrerelease: true,
- })
+ maybeDepMetadata.packageVersion &&
+ normalizedRange === maybeDepMetadata.packageVersion
) {
return maybeDep?.name;
}
+ if (
+ maybeDepMetadata.packageVersion &&
+ normalizedRange &&
+ normalizedRange !== '*'
+ ) {
+ try {
+ if (
+ satisfies(maybeDepMetadata.packageVersion, normalizedRange, {
+ includePrerelease: true,
+ })
+ ) {
+ return maybeDep?.name;
+ }
+ } catch (e) {
+ // If semver validation fails, don't resolve to workspace project
+ }
+ }
+
return null;
}
⚙️ An Nx Cloud workspace admin can disable these reviews in workspace settings.
11617ee
to
dc6f6c7
Compare
dc6f6c7
to
9c4b611
Compare
9c4b611
to
3d95a70
Compare
3d95a70
to
8f283fe
Compare
8f283fe
to
6ef92aa
Compare
6ef92aa
to
fcda2f9
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
The project graph build process incorrectly handles dependencies when workspace projects have
different versions or are referenced via specific version ranges. This causes several issues:
(which don't have versions)
"proj4": "1.0.0" when workspace has "version": "2.0.0") incorrectly resolve to the workspace
project instead of the installed npm package
Expected Behavior
The dependency resolution should:
referenced
wildcards
Notes
This has inadvertently caused issues when calculating which manifest files need to be updated in the JSVersionActions / Nx Release for Npm Packages
Related Issues
Fixes #31454