Skip to content

cleanup(core): use calculateHashesForCreateNodes for batch hashing in plugins#35561

Draft
FrozenPandaz wants to merge 4 commits intomasterfrom
refactor/calculate-hashes-for-create-nodes
Draft

cleanup(core): use calculateHashesForCreateNodes for batch hashing in plugins#35561
FrozenPandaz wants to merge 4 commits intomasterfrom
refactor/calculate-hashes-for-create-nodes

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

Current Behavior

15 inferred plugins call calculateHashForCreateNodes once per project inside their createNodesInternal callback. The single-project helper triggers a workspace-context glob per project, even when many projects are being processed in the same createNodesV2 invocation that all share context.workspaceRoot. There is already a batch helper, calculateHashesForCreateNodes, that runs a single multi-glob hash across all project roots — only vite, vitest, docker, and maven use it today. nuxt even has a TODO(@nrwl/nx-vue-reviewers): This should batch hashing like our other plugins comment to that effect.

In the same per-project path, several plugins also re-invoke getLockFileName(detectPackageManager(context.workspaceRoot)) once per project, which probes the lockfile redundantly.

Expected Behavior

Each affected plugin's createNodes callback now does the per-workspace work upfront:

  • Pre-filter configFiles into validConfigFiles + projectRoots (parallel arrays) using the existing sibling-file / metro / expo / remix-compiler checks.
  • Detect the package manager once and derive pmc and lockFileName from it.
  • Call calculateHashesForCreateNodes(projectRoots, options, context, additionalGlobsByProject) once.
  • Pass the pre-computed hash by index into createNodesInternal (4th idx arg from createNodesFromFiles).

Plugins migrated:

  • angular, cypress, detox, expo, gradle (v1 + v2 nodes), next, nuxt, playwright, react-native, remix, rollup, rsbuild, storybook, webpack.

gradle's exported makeCreateNodesForGradleConfigFile factory gains an optional hashes?: string[] parameter so external callers retain the previous single-shot behavior; when a hashes array is supplied, each callback invocation picks hashes[idx]. nuxt's TODO comment is removed since the batching is now in place.

rspack was not migrated — it does its own hashing with hashFile + hashArray + hashObject and never used calculateHashForCreateNodes.

For playwright, the additionalGlobs array is per-project (each project's externalTsconfigInputs), so the call passes projectRoots.map((_, idx) => [lockFileName, ...externalTsconfigInputsByIdx[idx]]).

All affected plugin specs (cypress, next, storybook, rsbuild, angular, playwright, webpack, rollup, nuxt, remix, gradle v1 + v2) pass locally.

Related Issue(s)

N/A — this is an internal refactor / performance cleanup, not a fix for a reported issue.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 26f9f47
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69fbacc42179e100087aab83
😎 Deploy Preview https://deploy-preview-35561--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 26f9f47
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69fbacc4f228c30008cfdf8e
😎 Deploy Preview https://deploy-preview-35561--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 4, 2026

View your CI Pipeline Execution ↗ for commit 26f9f47

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 46m 10s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 17s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 25s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 8s View ↗
nx affected -t e2e-macos-local --parallel=1 --b... ✅ Succeeded 39m 48s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-06 21:54:14 UTC

nx-cloud[bot]

This comment was marked as outdated.

… plugins

migrate inferred plugins from per-project calculateHashForCreateNodes to
the batch calculateHashesForCreateNodes helper. the batch variant runs a
single workspace-context glob across all project roots instead of one per
file, which is faster on large monorepos.

for each plugin:
- pre-filter configFiles into validConfigFiles + projectRoots upfront in
  the createNodes callback (sibling-file checks, etc).
- compute hashes once via calculateHashesForCreateNodes.
- pass the hash by index into createNodesInternal.
- also hoists detectPackageManager / getLockFileName out of the per-project
  path while we're here.

affects: angular, cypress, detox, expo, gradle (v1 + v2), next, nuxt,
playwright, react-native, remix, rollup, rsbuild, storybook, webpack.
@FrozenPandaz FrozenPandaz force-pushed the refactor/calculate-hashes-for-create-nodes branch from 9ff1667 to 917fc65 Compare May 5, 2026 23:27
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a possible root cause for your failed CI:

We classified this as an environment issue rather than a code change because the failure is caused by @angular-devkit/core@21.2.10 not yet being available on the npm registry (latest is 21.2.9), which is unrelated to this PR's batch hashing refactor. Our changes do not touch any Angular version constraints or dependency files, so re-running once the Angular release propagates should resolve the failure.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant