Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

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

Closed
cheer555 opened this issue Aug 22, 2017 · 6 comments

Comments

@cheer555
Copy link

I use webpack 2.6.1 + create-react-app+ happypack, and throw AssertionError: HappyPack: plugin for the loader '1' could not be found! Did you forget to add it to the plugin list?

  1. my webapck config
    image
    image
@nudoru
Copy link

nudoru commented Aug 25, 2017

Have the same issue. Looks like it doesn't work when you pass an id to the loader. This limits you to one Happypack loader at a time since you have no way to reference other.

This is a custom app, not one created w/ create-react-app

@amireh
Copy link
Owner

amireh commented Aug 26, 2017

Defining options is overriding the query that is specified in the loader string. Those options to babel need to be specified in the plugin's loader list, not in webpack's.

module: { rules: [{
  test: ...,
  // here you configure happypack; pass it the id
  loader: 'happypack/loader?id=happybabel',
}] },
...
plugins: [
  new HappyPack({
    id: 'happybabel',
    loaders: [{
      loader: 'babel-loader',
      // here you configure babel:
      options: { babelrc: true, cacheDirectory: true }
    }]
  })
]

That should fix it. Feel free to re-open if you're still having problems!

@amireh amireh closed this as completed Aug 26, 2017
@RickyLL
Copy link

RickyLL commented Dec 25, 2018

Defining options is overriding the query that is specified in the loader string. Those options to babel need to be specified in the plugin's loader list, not in webpack's.

module: { rules: [{
  test: ...,
  // here you configure happypack; pass it the id
  loader: 'happypack/loader?id=happybabel',
}] },
...
plugins: [
  new HappyPack({
    id: 'happybabel',
    loaders: [{
      loader: 'babel-loader',
      // here you configure babel:
      options: { babelrc: true, cacheDirectory: true }
    }]
  })
]

That should fix it. Feel free to re-open if you're still having problems!

Now,It still has this problem.

@bernatfortet
Copy link

Any updates on this one?

@amireh
Copy link
Owner

amireh commented Feb 26, 2019

I see the 😕 reactions on the response above. Let me try to explain it differently: a webpack loader can accept options as a string in the form of query:

loader: 'babel-loader?opt_one=a&opt_two=b'

But it can also accept options in a hash if you define the options property:

loader: {
  loader: 'babel-loader',
  options: { opt_one: 'a', opt_two: 'b' }
}

Defining both at the same time does not merge the options. It's either one or the other. In the original snippet, the loader happypack/loader was being passed a string-encoded set of options( ?id=happybabel) but then that same loader also had an options map which was meant for the underlying babel loader.

What I meant in my response is to move that options map to the loader definition inside HappyPlugin so that happypack itself passes those options to Babel. Remember that with the HappyPack setup, webpack no longer sees babel-loader directly, only happypack/loader.

So, this part of the snippet configures Webpack to use HappyPack's loader:

module: { rules: [{
  test: ...,
  // here you configure happypack; pass it the id
  loader: 'happypack/loader?id=happybabel',
}] }

Whereas this part of the snippet configures HappyPack to use Babel loader:

plugins: [
  new HappyPack({
    id: 'happybabel',
    loaders: [{
      loader: 'babel-loader',
      // here you configure babel:
      options: { babelrc: true, cacheDirectory: true }
    }]
  })
]

I hope that made it clear.

@guopingping
Copy link

it's no use, still has this problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants