babel plugins not recognized?
Using webpack v2 (2.2.1) + happypack 3.0.2 gives me a lot of these types of errors:
Module parse failed: /app/node_modules/happypack/loader.js?id=hp-babel!/somefile.js Unexpected token (107:19) You may need an appropriate loader to handle this file type.`
Without happypack, the build runs just fine which makes me suspect the .babelrc config which includes several plugins is not being used.
Here's some relevant config:
webpack.config.json
...
plugins:
new HappyPack({
// loaders is the only required parameter:
id: 'hp-babel',
loaders: ['babel-loader'],
verbose: true,
debug: true
}),
...
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: APP_PATH,
use: [
{
loader: 'happypack/loader?id=pack/loader?id=hp-babel'
}
]
},
...
.babelrc
{
"presets": [
[
"es2015",
{
"modules": false
}
],
"stage-0",
"react"
],
"plugins": [
"transform-decorators-legacy",
"transform-runtime",
"babel-plugin-transform-class-properties",
"transform-object-rest-spread"
],
"env": {
"production": {
"plugins": [
"transform-react-remove-prop-types"
]
}
}
}
Hey, can you please try out the master branch and see if it fixes the issue? It seems similar to #132.
Edit: in fact, version 3.0.3 on NPM now should incorporate the mentioned fix. You can try that instead of master.
I can confirm 3.0.3 fixes my issue, thanks man!
I'm using HappyPack v4.0.1 with webpack v3.8.1, babel-Loader v7.1.2, babel-preset-env v1.6.1 and babel-plugin-transform-object-rest-spread and I'm seeing the exact same problem.
I'm compiling for node and trying to use object-rest-spread. HappyPack seems to ignore my babel plugins if I include them in the webpack config OR in .babelrc. I get errors about using the ... operator.
If I remove happypack and just use a regular webpack loader it works fine.
Do you know if it's reading the .babelrc file at all? I assume it also includes presets along with the plugins, is it just the plugins that aren't recognized?
- If it's the entire file not being read, try setting the webpack "context" configuration parameter and see if that helps. It should point to your source code's root folder (or wherever the top-most
.babelrcfile lives in.) - Try also specifying the .babelrc file directly in your loader options just to troubleshoot what's going on. You can do it with something like:
new HappyPack({
id: 'hp-babel',
loaders: [{
loader: 'babel-loader',
options: { babelrc: path.resolve(__dirname, '.babelrc') } // or wherever
}],
verbose: true,
debug: true
}),
I've not seen such an issue with .babelrc so it's likely we're missing something else in the config.