Nx 22.7 release

Juri Strumpflohner
Published
Outline
Caching
Task Sandboxing
- main highlight
- 2 runs:
- config in Nx repo
Worktree caching demo (e.g. switching worktrees)
- just use juridev or the nx repo as the example, run a cache warmup, then switch to a worktree and re-running should still resolve the cache.
Caching fine-grained config
- show a concrete example of walking into the dependent project files. maybe with tests? come up with some concrete example
Demo workspace: ~/demos/2026-04-28-nx-caching/nxcaching
- 2 libs:
@org/utils(math.ts used, internal.ts unused) and@org/api(depends on utils, has vitest tests) apiimportsadd/multiplyfrom@org/utils, tests inapi.spec.ts
Setup before recording
cd ~/demos/2026-04-28-nx-caching/nxcaching
pnpm nx reset
pnpm nx test @org/api # warm cache, run twice so 2nd is full hit
pnpm nx test @org/api
Take 1 — pain (default config)
pnpm nx show project @org/api --web(or--json | jq .targets.test.inputs) → point out<a name="^production"></a>reaches into all of utils- Trivial edit in
packages/utils/README.md(append a line) pnpm nx test @org/api→ cache miss onapi:test. “I edited a README in a dep, why is my test cache busted?”- Revert README. Re-run → hit.
Take 2 — fix with ^{projectRoot}
Edit nx.json, add to targetDefaults:
"targetDefaults": {
"test": {
"inputs": [
"default",
"^{projectRoot}/src/**/*.ts",
{ "externalDependencies": ["vitest"] }
]
}
}
Drop the broad <a name="^production"></a> reach, walk straight into dep source.
pnpm nx reset && pnpm nx test @org/api(warm twice)- Edit
packages/utils/README.md→pnpm nx test @org/api→ cache hit ✅ - Edit
packages/utils/src/lib/internal.ts(logic change, e.g.[debug]→[debug-v2]) → still miss (it IS source — show that you can narrow further tosrc/math.tsif you want surgical scope) - Edit
packages/utils/src/lib/math.ts→ miss ✅ (correct) - Closing beat:
pnpm nx show project @org/api --json | jq .targets.test.inputsto display resolved inputs
JSON input type config
- show example of excluding package.json script changes from cache invalidation
Same workspace. packages/api/package.json already has both dependencies (@org/utils, tslib) and scripts (start, lint:fix).
Take 1 — pain
pnpm nx build @org/apiwarm → run twice for full hit- Edit
packages/api/package.json, changescripts.starttonode ./dist/main.js(or add a script) pnpm nx build @org/api→ cache miss. “I added a script, my build cache shouldn’t care.”
Take 2 — fix with json input
Edit packages/api/package.json (or pin via nx.json targetDefaults.build):
"nx": {
"targets": {
"build": {
"inputs": [
"production",
"!{projectRoot}/package.json",
{ "json": "{projectRoot}/package.json", "include": ["dependencies", "peerDependencies"] }
]
}
}
}
Exclude whole-file match, then hash only dependencies/peerDependencies.
pnpm nx reset && pnpm nx build @org/api(warm)- Edit
scripts.startagain →pnpm nx build @org/api→ cache hit ✅ - Bump a real dep version (e.g.
tslib) → cache miss ✅ - Closing beat:
pnpm nx show project @org/api --json | jq .targets.build.inputsto show the json input + included fields
Nx import
I have a demo prepped in:Agentic Nx Import: Let an Agent Drive Your Monorepo Migrations
Mention other agentic improvements
Mention improvements on nx init and nx configure-ai-agents.
Nx perf
- Memory: nx cloud
- show the blog post section with the results.