juri.dev / videos

Nx 22.7 release

Author profile pic
Juri Strumpflohner
Published

Outline

Caching

Task Sandboxing

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)
  • api imports add/multiply from @org/utils, tests in api.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)

  1. pnpm nx show project @org/api --web (or --json | jq .targets.test.inputs) → point out <a name="^production"></a> reaches into all of utils
  2. Trivial edit in packages/utils/README.md (append a line)
  3. pnpm nx test @org/api → cache miss on api:test. “I edited a README in a dep, why is my test cache busted?”
  4. 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.

  1. pnpm nx reset && pnpm nx test @org/api (warm twice)
  2. Edit packages/utils/README.mdpnpm nx test @org/apicache hit
  3. 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 to src/math.ts if you want surgical scope)
  4. Edit packages/utils/src/lib/math.ts → miss ✅ (correct)
  5. Closing beat: pnpm nx show project @org/api --json | jq .targets.test.inputs to 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

  1. pnpm nx build @org/api warm → run twice for full hit
  2. Edit packages/api/package.json, change scripts.start to node ./dist/main.js (or add a script)
  3. 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.

  1. pnpm nx reset && pnpm nx build @org/api (warm)
  2. Edit scripts.start again → pnpm nx build @org/apicache hit
  3. Bump a real dep version (e.g. tslib) → cache miss ✅
  4. Closing beat: pnpm nx show project @org/api --json | jq .targets.build.inputs to 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.