HappyPack

raw JSON →
5.0.1 verified Sat Apr 25 auth: no javascript maintenance

HappyPack accelerates webpack builds by parallelizing file transformations across multiple Node.js worker threads. Version 5.0.1 (last release) is in maintenance mode; the author recommends webpack 4+'s built-in thread-loader for new projects. Key differentiator: it was the first widely-adopted parallel loader for webpack 1-3, but it has limited support for certain webpack loader APIs and is not actively developed. It remains useful for legacy webpack setups where migration to thread-loader is not feasible.

error Error: Cannot find module 'happypack/loader'
cause happypack not installed or path resolved incorrectly.
fix
Run 'npm install --save-dev happypack' and ensure the loader string is exactly 'happypack/loader'.
error Module build failed: Error: HappyPack: plugin for the loader 'happypack/loader' is not defined
cause Missing or misconfigured Happypack plugin instance in webpack plugins array.
fix
Add a new HappyPack({ loaders: [...] }) to the plugins array.
error TypeError: Cannot read property 'getOptions' of undefined
cause Using a webpack loader that expects the 'this.getOptions()' API, not supported by HappyPack.
fix
Use a loader that doesn't rely on that API, or switch to thread-loader.
deprecated HappyPack is in maintenance mode; author recommends thread-loader for webpack 4+.
fix Migrate to thread-loader for webpack 4+ or use webpack 5's built-in parallelism.
gotcha Does not support all webpack loader APIs (e.g., pitch loaders, loader context methods).
fix Check the wiki for supported API; avoid loaders that rely on unsupported features.
gotcha Requires same major version of webpack as the project; incompatible across webpack 1/2/3/4 without careful version matching.
fix Pin happypack version to match your webpack version (e.g., happypack@5 for webpack 4).
breaking Happypack 5.x drops support for webpack 3 and below; only webpack 4 supported.
fix Use happypack@4 if you are on webpack 3 or older.
npm install happypack
yarn add happypack
pnpm add happypack

Basic webpack config using HappyPack to parallelize Babel transpilation of .js files.

// webpack.config.js
const HappyPack = require('happypack');

module.exports = {
  entry: './src/index.js',
  output: { filename: 'bundle.js' },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: 'happypack/loader',
        exclude: /node_modules/
      }
    ]
  },
  plugins: [
    new HappyPack({
      loaders: ['babel-loader?presets[]=@babel/preset-env']
    })
  ]
};