fix(core): improve package-json createNode performance#33960
fix(core): improve package-json createNode performance#33960FrozenPandaz merged 4 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
View your CI Pipeline Execution ↗ for commit d8986b2
☁️ Nx Cloud last updated this comment at |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
e5bd702 to
898448f
Compare
Co-authored-by: meeroslav <meeroslav@users.noreply.github.com>
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
These changes fix the TypeScript compilation error by updating the call site in packages/nx/plugins/package-json.ts to match the refactored function signature. The fix calls buildPackageJsonPatterns() first to generate the patterns object with performance-optimized lookup tables, then passes that object to buildPackageJsonWorkspacesMatcher(), maintaining the PR's performance improvements while resolving the TS2554 error across all test suites.
We verified this fix by re-running docker:test, express:test, nest:test.
diff --git a/packages/nx/plugins/package-json.ts b/packages/nx/plugins/package-json.ts
index 53a032fe0c..335af6b85e 100644
--- a/packages/nx/plugins/package-json.ts
+++ b/packages/nx/plugins/package-json.ts
@@ -1,6 +1,7 @@
import { createNodesFromFiles, NxPluginV2 } from '../src/project-graph/plugins';
import { workspaceRoot } from '../src/utils/workspace-root';
import {
+ buildPackageJsonPatterns,
buildPackageJsonWorkspacesMatcher,
createNodeFromPackageJson,
} from '../src/plugins/package-json';
@@ -34,10 +35,11 @@ const plugin: NxPluginV2 = {
(configFiles, options, context) => {
const cache = readPackageJsonConfigurationCache();
- const isInPackageJsonWorkspaces = buildPackageJsonWorkspacesMatcher(
- context.workspaceRoot,
- (f) => readJsonFile(join(context.workspaceRoot, f))
+ const patterns = buildPackageJsonPatterns(context.workspaceRoot, (f) =>
+ readJsonFile(join(context.workspaceRoot, f))
);
+ const isInPackageJsonWorkspaces =
+ buildPackageJsonWorkspacesMatcher(patterns);
const result = createNodesFromFiles(
(packageJsonPath) =>
Or Apply changes locally with:
npx nx-cloud apply-locally fJ2V-8skl
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
|
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. |

On test repo, the
package-json:createNodes:isInPackageManagerWorkspacesTimetakes:This is achieved by avoiding unnecessary use of
minimatchwhen a direct string comparison is sufficient.It also makes creation and logging of entire graph come down from
23.6sdown to18.5sCurrent Behavior
Expected Behavior
Related Issue(s)
Fixes #