v8-compile-cache icon indicating copy to clipboard operation
v8-compile-cache copied to clipboard

Install / uninstall programmatically?

Open cspotcode opened this issue 3 years ago • 1 comments

Is there a way to use v8-compile-cache as a library?

My use-case is to programmatically install the compile cache, then uninstall it, and for other code in node to be able to require('v8-compile-cache') and for it to install correctly.

Right now, if I temporarily override the env var to prevent installation, I can get access to __TEST__ but it will also prevent subsequent code from calling require('v8-compile-cache') because it is in require() cache already. I'm also not sure __TEST__ can be relied on as a stable API surface.

cspotcode avatar Mar 02 '21 21:03 cspotcode

I created this to expose functionality as a library for programmatic usage. Not thoroughly tested, YMMV.

https://github.com/cspotcode/v8-compile-cache-lib https://www.npmjs.com/package/v8-compile-cache-lib

The changes are minimal so we could definitely merge them back into here if desired.

cspotcode avatar Mar 21 '21 19:03 cspotcode