lazy-cache v2.0.2 is a tiny utility that defers requiring npm modules until they are actually accessed. It uses JavaScript getters to lazily load dependencies, which can reduce startup time and avoid executing problematic code from dependencies (e.g., libraries that modify globals or run side effects on require). The package is stable but effectively in maintenance mode (last release 2018). Key differentiators: no magic, native getters; works with CommonJS; has a separate webpack loader for bundler compatibility. However, it is largely superseded by ESM dynamic imports and tree-shaking.
npm install lazy-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to require the lazy-cache function, register modules, and use them lazily with both property access and aliased function style.
Use the unlazy-loader (https://github.com/doowb/unlazy-loader) as a webpack plugin.
Use require() or migrate to ESM dynamic import() which serves a similar purpose natively.
Consider using ES2020 dynamic import() for modern projects, or a more maintained lazy-loading library.
Always call as `require('lazy-cache')(require)`.Run `npm install lazy-cache` and ensure you are using `require('lazy-cache')` (CommonJS).Use `const lazy = require('lazy-cache')(require);`Add the unlazy-loader to webpack config, or avoid using lazy-cache with webpack.
No dependency data recorded yet.