{"id":45077,"library":"hadron-compile-cache","title":"Hadron Compile Cache","description":"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.","status":"active","version":"4.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/mongodb-js/compass","tags":["javascript","mongodb-js"],"install":[{"cmd":"npm install hadron-compile-cache","lang":"bash","label":"npm"},{"cmd":"yarn add hadron-compile-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add hadron-compile-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for internal utilities like assigning home directory settings","package":"lodash","optional":false}],"imports":[{"note":"CJS only; package does not offer ESM exports. Default export is the CompileCache constructor.","wrong":"import CompileCache from 'hadron-compile-cache';","symbol":"CompileCache","correct":"const CompileCache = require('hadron-compile-cache');"},{"note":"setHomeDirectory is a static method on CompileCache. Must be called before using the cache.","wrong":"setHomeDirectory(path);","symbol":"setHomeDirectory","correct":"CompileCache.setHomeDirectory(path);"},{"note":"Static method to clear the home directory setting.","wrong":null,"symbol":"resetHomeDir","correct":"CompileCache.resetHomeDir();"},{"note":"Static method to clear all cached compilation results.","wrong":null,"symbol":"clearCache","correct":"CompileCache.clearCache();"}],"quickstart":{"code":"const path = require('path');\nconst CompileCache = require('hadron-compile-cache');\n\n// Must set a home directory before requiring files\nconst home = path.join(__dirname, 'cache-root');\nCompileCache.setHomeDirectory(home);\n\n// Now any require for .jsx/.js will be cached\nrequire('./some-jsx-file.jsx');\n\n// Clear cache if needed\nCompileCache.clearCache();\n\nconsole.log('Compiled and cached successfully.');","lang":"javascript","description":"Sets up compile cache with a custom home directory and demonstrates requiring a JSX file."},"warnings":[{"fix":"Call CompileCache.setHomeDirectory(home) at application startup before requiring any files to be cached.","message":"CompileCache.setHomeDirectory() must be called before any require of cached files, otherwise the cache will not be active and files will compile normally.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use CommonJS require() instead of ESM import.","message":"Package does not support ESM imports (import syntax). Attempting to import will cause a SyntaxError or Module not found.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"N/A","message":"No known deprecated features in current version.","severity":"deprecated","affected_versions":"4.4.0"}],"env_vars":null,"search_vec":"'4.4.0':21 'base':35 'break':76 'bump':83 'cach':3,6,33 'cadenc':66 'chang':77 'compass':63,70 'compil':2,7,32 'differ':42 'directori':56 'e.g':10 'environ':19 'file':37 'generic':44 'hadron':1,53 'home':55 'hook':47 'infrequ':74 'integr':51 'intercept':30 'javascript':8,84 'js':87 'jsx':11 'librari':48 'major':81 'modif':40 'modul':9,31 'mongodb':62,86 'mongodb-j':85 'node.js':18 'optim':60 'path':38 'possibl':79 'releas':25,65,71 'requir':16,46 'require-hook':45 'require.extensions':28 'result':34 'set':57 'speed':13 'stabl':24 'subsequ':15 'tie':68 'time':41 'updat':72 'usag':64 'util':4 'version':20,82 'wrap':27","created_at":"2026-06-07T12:53:15.016698+00:00","updated_at":"2026-06-07T12:53:15.016698+00:00","problems":[{"fix":"Use const CompileCache = require('hadron-compile-cache');","cause":"Importing the package incorrectly (e.g., using default import instead of require).","error":"TypeError: CompileCache.setHomeDirectory is not a function"},{"fix":"Ensure the home directory exists and the process has write permissions.","cause":"Home directory provided to setHomeDirectory does not exist or is not writable.","error":"Error: ENOENT: no such file or directory, open '...' (cache miss)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mongodb-js/compass","github":"https://github.com/mongodb-js/compass","docs":null,"changelog":null,"pypi":null,"npm":"hadron-compile-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}