unlazy-loader
raw JSON → 0.1.3 verified Sat Apr 25 auth: no javascript deprecated
Webpack loader that transforms source files using lazy-cache into files that require modules directly, effectively 'unlazy-ing' cached requires for bundling. Version 0.1.3, last updated in 2016, no recent releases. Intended for use with webpack and the deprecated lazy-cache pattern. Limited documentation, no tests visible, and no maintenance activity. Alternatives like babel-plugin-lazy-cache or direct imports are recommended.
Common errors
error Module not found: Error: Can't resolve 'unlazy-loader' ↓
cause unlazy-loader is not installed or not resolved correctly.
fix
Run 'npm install unlazy-loader --save-dev' and ensure it's in the project's node_modules.
error Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. ↓
cause Using webpack v2+ with 'loaders' array instead of 'rules' array.
fix
Change 'module.loaders' to 'module.rules' and 'loader' to 'use' in webpack config.
error lazy-cache requires a require function to be passed ↓
cause The lazy-cache function was not called with the require context; this loader expects specific usage.
fix
Ensure you use 'const lazy = require('lazy-cache')(require)' in your source files.
Warnings
deprecated Package is effectively unmaintained since 2016. No updates for Node.js or webpack compatibility. Use at your own risk. ↓
fix Consider using babel-plugin-lazy-cache or manually converting lazy-cache calls to direct imports.
breaking Webpack v2+ changed loader configuration syntax. Using old 'loaders' array and 'loader' property may fail silently or produce errors. ↓
fix Update webpack config to use 'rules' array and 'use' property.
gotcha The loader expects lazy-cache to be used with require context (commonjs). It may not work with ES module imports. ↓
fix Ensure your source files use CommonJS require pattern for lazy-cache (e.g., const lazy = require('lazy-cache')(require)).
Install
npm install unlazy-loader yarn add unlazy-loader pnpm add unlazy-loader Imports
- unlazy-loader (webpack rule configuration) wrong
module.exports = { module: { loaders: [ { test: /\.js$/, loader: 'unlazy' } ] } }correctmodule.exports = { module: { rules: [ { test: /\.js$/, use: 'unlazy-loader' } ] } } - lazy-cache wrong
const lazy = require('lazy-cache')(require); const foo = lazy('foo');correctimport lazyCache from 'lazy-cache'; const lazy = lazyCache(require); const foo = lazy('foo'); - webpack configuration (module.rules) wrong
{ test: /\.js$/, loader: 'unlazy' }correct{ test: /\.js$/, use: 'unlazy-loader' }
Quickstart
// 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'
}
]
}
};