fix(core): enable V8 module compilation cache in bin/nx.ts#35603
fix(core): enable V8 module compilation cache in bin/nx.ts#35603FrozenPandaz wants to merge 1 commit intonrwl:masterfrom
Conversation
Node 22.8+ ships an opt-in cache for compiled JS modules. Calling `enableCompileCache()` at the top of bin/nx.ts skips the parse + compile step for nx's JS modules on subsequent CLI invocations. The optional chaining + try/catch makes it a no-op on older Node versions, and the cache itself is a no-op on the first run; every run after that pays only the cached-bytecode load. Hot-cache run-many --parallel 10 over 5 next.js apps: before: 210ms median wall time after: 200ms median wall time
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
|
View your CI Pipeline Execution ↗ for commit 01e52af
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:
We identified this failure as an environment issue unrelated to the PR's changes. The e2e test cannot install @angular-devkit/core@21.2.10 because that version has not yet been published to the npm registry (latest available is 21.2.9). No action is needed on our end — the failure will resolve once the Angular team publishes the missing package version.
No code changes were suggested for this issue.
You can trigger a rerun by pushing an empty commit:
git commit --allow-empty -m "chore: trigger rerun"
git push
🔔 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
Every
nxinvocation re-parses and re-compiles the same JS modules from disk. Node 22.8+ ships an opt-in V8 cache for compiled bytecode (require('module').enableCompileCache()), but bin/nx.ts doesn't enable it.Expected Behavior
Call
enableCompileCache()at the top of bin/nx.ts so the cached bytecode is reused on subsequent runs. The optional chaining (?.) plus try/catch make it a no-op on older Node versions, and the cache itself is a no-op on the first run — every run after that pays only the cached-bytecode load instead of full parse+compile.Cache files live in Node's default location (
os.tmpdir()/node-compile-cache) and Node manages them automatically. Cache entries are keyed on source mtime+size and Node version, so they invalidate automatically when source changes or the user upgrades Node.Measured on a hot-cache
run-many --parallel 10over 5 next.js apps:Related Issue(s)
Fixes #