Repository navigation
enable node compile cache - #2171
Conversation
🦋 Changeset detectedLatest commit: 4c73d8f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2171 +/- ##
=======================================
Coverage 83.02% 83.02%
=======================================
Files 76 76
Lines 2981 2981
Branches 815 815
=======================================
Hits 2475 2475
Misses 459 459
Partials 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if (globalThis.process?.getBuiltinModule) { | ||
| const { enableCompileCache } = | ||
| globalThis.process.getBuiltinModule("node:module"); | ||
| enableCompileCache(); |
There was a problem hiding this comment.
q: could this be enabled in ./index.ts? or does this have to be enabled before loading the code? I just wonder cause it feels that perhaps at some point we should get rid of ./bin.js but maybe this compilation makes it necessary?
There was a problem hiding this comment.
it has to be enabled before importing the code that should be cached, it won't be cached if it's already loaded.
you can see this in typescript as well
you can also enable it permanently for everything with NODE_COMPILE_CACHE=/some/path/to/cache and NODE_COMPILE_CACHE_PORTABLE=1
There was a problem hiding this comment.
ok, cool - then I feel less bad now about the ./bin.js+./index.js split :p there is an actual reason for it now 👍
https://nodejs-api-docs-tooling.vercel.app/module.html#module-compile-cache