Skip to content

perf(monorepo): ⚡️ optimize nx local task caching across workspace#84

Open
JimmyPaolini wants to merge 10 commits into
mainfrom
jimmypaolini/copilot/optimize-nx-local-caching
Open

perf(monorepo): ⚡️ optimize nx local task caching across workspace#84
JimmyPaolini wants to merge 10 commits into
mainfrom
jimmypaolini/copilot/optimize-nx-local-caching

Conversation

@JimmyPaolini

Copy link
Copy Markdown
Owner

🌰 Summary

This PR optimizes Nx local task caching across the entire monorepo workspace. Implements deterministic cache behavior for build, test, lint, and code analysis targets without Nx Cloud, enabling faster iteration loops through intelligent cache invalidation boundaries and precise input/output definitions.

📝 Details

  • Refined nx.json caching strategy: Introduced workspaceConfiguration and ciConfiguration named inputs to minimize global invalidation scope; narrowed production and test input exclusions to improve cache hit rates.
  • Root project.json improvements: Split measure-code into cached check mode and uncached write mode; added explicit uncached rationale for 13 runtime-dependent targets (security audits, git hooks, infrastructure state).
  • Project-level cache alignment: Converted code-analysis targets in caelundas, lexico-ingestion, and synchronization to deterministic cached wrappers.
  • Generator template propagation: Updated NestJS command and GraphQL application templates to include cached code-analysis targets so all future generated projects inherit caching defaults.
  • Conformance test assertions: Added test coverage for required cache behavior in generated project configurations.
  • Cache determinism validated: Verified nx affected --target=<check-target> correctly reuses cache when only non-dependency files change, and invalidates when actual code/config changes.

🧪 Testing

Run the following to verify cache behavior and workspace graph correctness:

# Verify project configs parse correctly
pnpm nx show project monorepo --json | jq .targets | head -n 50

# Check affected graph with and without file changes (cache hit verification)
pnpm nx affected --target=measure-code --base=main --outputStyle=static
touch package.json
pnpm nx affected --target=measure-code --base=main --outputStyle=static
git checkout package.json

# Run analyze-code on affected projects (deterministic caching)
pnpm nx affected --target=analyze-code --configuration=check --base=main

# Confirm no Nx Cloud references in CI
grep -r 'nx.*cloud\|NX_CLOUD' .github/workflows .github/actions || echo 'No Nx Cloud references found'

🔗 Related

  • Implements local-only caching strategy without external cloud services
  • Supports faster developer feedback loops through precise cache invalidation boundaries
  • Planning document: documentation/planning/2026-07-06T19:50:45Z-infrastructure-nx-local-caching-optimization.plan.md

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

📦 Bundle Size Report

326.29 kB total (+0.00 kB, +0.0% vs base)

Bundle PR Size Base Size Diff Limit
Client JS 119.80 kB 119.80 kB +0.00 kB 175.78 kB
Client CSS 14.96 kB 14.96 kB +0.00 kB 19.53 kB
Library bundle 191.53 kB 191.53 kB +0.00 kB 24.41 kB
📊 Guidelines
  • ✅ Size decreased or unchanged
  • ⚠️ Increased < 5%
  • 📈 Increased ≥ 5%
  • ❌ Exceeds limit

Updated automatically when you push new commits.

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