Open
Description
Adding Compile-Caching Entry Points
- Node.js now supports V8 compilation caching.
- Recent PR to Node.js to add
module.enableCompilerCache()
. - Previously were ways to do this with 3rd party packages on npm.
- Recent PR to Node.js to add
- Node.js doesn't do this by default, but things like ts-node does on supported versions of Node.js.
- What's the downside?
- You need to have
require
to make this work, awkward for ESM. - This is being worked on.
- You need to have
- tsc and tsserver start up about 2.3x faster.
- For executables this is a no-brainer. We can actually use
import()
there too. - For libraries, questionable. So the PR doesn't do it.
- The PR must introduce a new entry point for the library. Is this worth the perf improvement?
- Yes.
- Just add a comment telling people what's going on and it's fine.
- Another risk - in development we recompile over and over, and that can pollute the cache.
- The files are pretty small - not a huge risk.
- We can add
hereby clear-node-cache
.
- Not going to be immediate - Node-specific work would need to be back-ported in in Node.js 22; otherwise only noticeable in Node 23+.
Activity