Registry / devops / hadron-compile-cache

hadron-compile-cache

JSON →
library4.4.0jsnpmunverified

Utility for caching compiled JavaScript modules (e.g., JSX) to speed up subsequent requires in Node.js environments. Version 4.4.0 is the stable release. It wraps `require.extensions` to intercept module compilation, caching results based on file path and modification time. Different from generic require-hook libraries because it integrates with Hadron's home directory settings and is optimized for MongoDB Compass usage. Release cadence is tied to Compass releases; updates are infrequent but breaking changes are possible with major version bumps.

npm install hadron-compile-cache
INSTALL
IMPORT
SIG · HADRON-COMPILE-CAC
H
hadron-compile-cache
devopsjavascriptv4.4.0
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.

CompileCache
const CompileCache = require('hadron-compile-cache');
import CompileCache from 'hadron-compile-cache';
CJS only; package does not offer ESM exports. Default export is the CompileCache constructor.
setHomeDirectory
CompileCache.setHomeDirectory(path);
setHomeDirectory(path);
setHomeDirectory is a static method on CompileCache. Must be called before using the cache.
resetHomeDir
CompileCache.resetHomeDir();
Static method to clear the home directory setting.
clearCache
CompileCache.clearCache();
Static method to clear all cached compilation results.

Sets up compile cache with a custom home directory and demonstrates requiring a JSX file.

const path = require('path'); const CompileCache = require('hadron-compile-cache'); // Must set a home directory before requiring files const home = path.join(__dirname, 'cache-root'); CompileCache.setHomeDirectory(home); // Now any require for .jsx/.js will be cached require('./some-jsx-file.jsx'); // Clear cache if needed CompileCache.clearCache(); console.log('Compiled and cached successfully.');
Debug
Known issues
breakingCompileCache.setHomeDirectory() must be called before any require of cached files, otherwise the cache will not be active and files will compile normally.
fix
Call CompileCache.setHomeDirectory(home) at application startup before requiring any files to be cached.
affects: >=1.0.0
gotchaPackage does not support ESM imports (import syntax). Attempting to import will cause a SyntaxError or Module not found.
fix
Use CommonJS require() instead of ESM import.
affects: >=4.0.0
deprecatedNo known deprecated features in current version.
fix
N/A
affects: 4.4.0
Errors
Common errors & fixes
TypeError: CompileCache.setHomeDirectory is not a function
Importing the package incorrectly (e.g., using default import instead of require).
fix
Use const CompileCache = require('hadron-compile-cache');
Error: ENOENT: no such file or directory, open '...' (cache miss)
Home directory provided to setHomeDirectory does not exist or is not writable.
fix
Ensure the home directory exists and the process has write permissions.
Upgrade
Version history
4.4.0latest on npm
Audit
Dependencies
lodashrequiredUsed for internal utilities like assigning home directory settings
Agent activity
12 hits · last 30 days
node
12
Resources
hadron-compile-cache — npm install hadron-compile-cache · libregistry