amireh / happypack

Happiness in the form of faster webpack build times.
MIT License
4.23k stars 124 forks source link

[AssertionError [ERR_ASSERTION]]:HappyPack: plugin for the loader '1' could not be found! Did you forget to add it to the plugin list? #238

Closed Fiv5 closed 4 years ago

Fiv5 commented 6 years ago

webpack version : v4.12.0 happypack version : v5.0.0 this is my webpack config :

// module
 module: {
    rules: [
...,
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        exclude: /node_modules/,
        use: {
          loader: 'happypack/loader?id=babel',
          options: {
            // 缓存
            cacheDirectory: true,
          },
        },
      },
...}
//plugins:
   new HappyPack({
      // 基础参数设置
      id: 'babel', // 上面loader?后面指定的id
      // loaders: ['babel-loader?cacheDirectory'], // 实际匹配处理的loader
      loaders: [
        {
          path: 'babel-loader',
          query: {
            babelrc: true,
            cacheDirectory: true,
          },
        },
      ], // 实际匹配处理的loader
      threadPool: happyThreadPool,
      // cache: true // 已被弃用
    }),
FEYeh commented 6 years ago

have same questions

xcondor commented 5 years ago

Which webpack version supported happypack? I used webpack 3.6.0, the same to above question.

yannickguillemot commented 5 years ago

Same here. Any updates on this?

amireh commented 5 years ago

The options defined inside the module.rules is overriding the query string (?id=babel) so happypack's loader is looking for the default plugin instance (named "1"). Can't have both at the same time.

You're already configuring the babel loader properly (inside the happy plugin instance) so just omit the options from the module.rules entry.

Relevant snippets:

module: {
  rules: [
    {
      test: /\.js$/,
      use: 'happypack/loader?id=babel',
      // don't put options here, or put options with { id: 'babel' }
    }
  ]
}
hanwenbo commented 5 years ago

This bug is too serious to use,Most loaders have this error

RickyLL commented 5 years ago

The options defined inside the module.rules is overriding the query string (?id=babel) so happypack's loader is looking for the default plugin instance (named "1"). Can't have both at the same time.

You're already configuring the babel loader properly (inside the happy plugin instance) so just omit the options from the module.rules entry.

Relevant snippets:

module: {
  rules: [
    {
      test: /\.js$/,
      use: 'happypack/loader?id=babel',
      // don't put options here, or put options with { id: 'babel' }
    }
  ]
}

Your offered solution can not fix this problem

romanlex commented 5 years ago

Same here. Any updates on this?

amireh commented 5 years ago

How does it not fix the problem? What do you see after amending the options? Please see my response for this similar thread.

We've been using multiple loaders since v1 of this plugin and the tests do cover this use case.

Zwe1 commented 4 years ago

@amireh it helps a lot, i fix it