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.

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.
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)).
npm install unlazy-loader
yarn add unlazy-loader
pnpm add unlazy-loader

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'
      }
    ]
  }
};