Registry / devops / v8-compile-cache-lib

v8-compile-cache-lib

JSON →
library3.0.1jsnpmunverified

Fork of v8-compile-cache exposing an API for programmatic usage. Current stable version is 3.0.1. It installs a require hook that uses V8's code cache to speed up module compilation, reducing instantiation time by 20-50% in benchmarks. Key differentiators: provides an install() function instead of requiring --require flag, supports custom cache directory via environment variable, and can be disabled. Requires Node >=4.0.0 (module uses ES2015).

npm install v8-compile-cache-lib
INSTALL
IMPORT
SIG · V8-COMPILE-CACHE-L
V
v8-compile-cache-lib
devopsjavascriptv3.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import install from 'v8-compile-cache-lib'
import { install } from 'v8-compile-cache-lib'
Default export is the install function. Named import will not work.
install
const install = require('v8-compile-cache-lib')
const { install } = require('v8-compile-cache-lib')
CommonJS require returns the install function directly, not an object.
V8CompileCache
import V8CompileCache from 'v8-compile-cache-lib'
import * as V8CompileCache from 'v8-compile-cache-lib'
No namespace export; use default import for the function.

Shows how to install the V8 compile cache hook in an entry module.

// Entry point: index.js require('v8-compile-cache-lib').install(); // Your app code console.log('App started'); // To disable: set DISABLE_V8_COMPILE_CACHE=1 before requiring // To customize cache dir: set V8_COMPILE_CACHE_CACHE_DIR=/path/to/cache
Debug
Known issues
gotchainstall() is a noop on Node <5.7.0, but module uses ES2015 syntax requiring Node >=4.0.0
fix
Upgrade Node to at least 5.7.0 or accept the noop
affects: <5.7.0
gotchaCache is per-entry module; loading a different entry module will not use the same cache
fix
Ensure the same entry module is used each time to benefit from caching
affects: >=3.0.0
gotchaEnvironment variable DISABLE_V8_COMPILE_CACHE=1 must be set before requiring the module
fix
Set variable at process start, e.g., process.env.DISABLE_V8_COMPILE_CACHE = '1'
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'v8-compile-cache-lib'
Package not installed
fix
Run: npm install v8-compile-cache-lib
TypeError: require(...).install is not a function
Using destructuring on require result, e.g., const { install } = require(...)
fix
Use: const install = require('v8-compile-cache-lib'); install();
SyntaxError: Unexpected token import
Using ES module import syntax in a CommonJS context
fix
Use require instead of import: const install = require('v8-compile-cache-lib')
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
v8-compile-cache-lib — npm install v8-compile-cache-lib · libregistry