Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
unlazy-loader (webpack rule configuration)
✓ module.exports = { module: { rules: [ { test: /\.js$/, use: 'unlazy-loader' } ] } }
✗ module.exports = { module: { loaders: [ { test: /\.js$/, loader: 'unlazy' } ] } }
Webpack v1 uses 'loaders' and 'loader' (string); v2+ uses 'rules' and 'use'. The documentation uses v1 style.
lazy-cache
✓ import lazyCache from 'lazy-cache'; const lazy = lazyCache(require); const foo = lazy('foo');
✗ const lazy = require('lazy-cache')(require); const foo = lazy('foo');
This loader is designed to transform lazy-cache calls; it does not replace the import itself.
webpack configuration (module.rules)
✓ { test: /\.js$/, use: 'unlazy-loader' }
✗ { test: /\.js$/, loader: 'unlazy' }
In webpack v4+, 'loader' is deprecated in favor of 'use'. The short name 'unlazy' works if resolveLoader is configured, but explicit 'unlazy-loader' is safer.
Basic webpack configuration to apply unlazy-loader to all JavaScript files, transforming lazy-cache requires into direct requires.
// webpack.config.js
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
use: 'unlazy-loader'
}
]
}
};
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'unlazy-loader'
unlazy-loader is not installed or not resolved correctly.
fixRun 'npm install unlazy-loader --save-dev' and ensure it's in the project's node_modules.
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
Using webpack v2+ with 'loaders' array instead of 'rules' array.
fixChange 'module.loaders' to 'module.rules' and 'loader' to 'use' in webpack config.
lazy-cache requires a require function to be passed
The lazy-cache function was not called with the require context; this loader expects specific usage.
fixEnsure you use 'const lazy = require('lazy-cache')(require)' in your source files. Audit
Dependencies
webpackrequiredRequired as peer dependency; this is a webpack loader.
lazy-cacheoptionalThe loader transforms files that use lazy-cache; lazy-cache should be a dependency of the project.