cleanup(core): use calculateHashesForCreateNodes for batch hashing in plugins#35561
cleanup(core): use calculateHashesForCreateNodes for batch hashing in plugins#35561FrozenPandaz wants to merge 4 commits intomasterfrom
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 26f9f47
☁️ Nx Cloud last updated this comment at |
… 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.
9ff1667 to
917fc65
Compare
… plugins [Self-Healing CI Rerun]
… plugins [Self-Healing CI Rerun]
There was a problem hiding this comment.
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:
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
Current Behavior
15 inferred plugins call
calculateHashForCreateNodesonce per project inside theircreateNodesInternalcallback. The single-project helper triggers a workspace-context glob per project, even when many projects are being processed in the samecreateNodesV2invocation that all sharecontext.workspaceRoot. There is already a batch helper,calculateHashesForCreateNodes, that runs a single multi-glob hash across all project roots — onlyvite,vitest,docker, andmavenuse it today.nuxteven has aTODO(@nrwl/nx-vue-reviewers): This should batch hashing like our other pluginscomment 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
createNodescallback now does the per-workspace work upfront:configFilesintovalidConfigFiles+projectRoots(parallel arrays) using the existing sibling-file / metro / expo / remix-compiler checks.pmcandlockFileNamefrom it.calculateHashesForCreateNodes(projectRoots, options, context, additionalGlobsByProject)once.createNodesInternal(4thidxarg fromcreateNodesFromFiles).Plugins migrated:
angular,cypress,detox,expo,gradle(v1 + v2 nodes),next,nuxt,playwright,react-native,remix,rollup,rsbuild,storybook,webpack.gradle's exportedmakeCreateNodesForGradleConfigFilefactory gains an optionalhashes?: string[]parameter so external callers retain the previous single-shot behavior; when ahashesarray is supplied, each callback invocation pickshashes[idx].nuxt's TODO comment is removed since the batching is now in place.rspackwas not migrated — it does its own hashing withhashFile+hashArray+hashObjectand never usedcalculateHashForCreateNodes.For
playwright, theadditionalGlobsarray is per-project (each project'sexternalTsconfigInputs), so the call passesprojectRoots.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.