Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Webpack 3.10.0 incompatibility #28

Closed
montogeek opened this issue Feb 12, 2018 · 2 comments
Closed

Webpack 3.10.0 incompatibility #28

montogeek opened this issue Feb 12, 2018 · 2 comments

Comments

@montogeek
Copy link
Contributor

montogeek commented Feb 12, 2018

Hello again!
Webpack 3.10.0 allows you to pass an array of rules using the rules or loaders key:

module: {
	loaders: [
	  {
	    test: /\.handlebars$/,
	    exclude: /(node_modules|bower_components|public\/)/,
	    use: [
	      {
	        loader: 'handlebars-loader',
	        options: { inlineRequires: 'static/icons' }
	      }
	    ]
	  },
	]
}

But this plugin only checks for the rules key, since it is undefined, it would reset the rules, deleting the user loaders configuration:

if (typeof changedCompiler.options.module.rules === 'undefined') {
changedCompiler.options.module.rules = [];
}

I guess webpack supports this for historical reasons, I am not sure if the plugin should handle this case or the user should be more careful with its webpack configuration or webpack should no support it.

More info in the webpack migration guide: https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules
Source code on webpack side: https://github.com/webpack/webpack/blob/f352436a0fd6491b8cc1aadeddfbe02c878686ff/lib/NormalModuleFactory.js#L49

As you can see rules is used if defined.

This bug was introduced in #20

Since it is supported by webpack I think the plugin should support it.

The solution should be adding an additional check for loaders key.

@kamilogorek
Copy link
Contributor

Fix published as 1.3.3. Please let us know if it solves the issue :)

@montogeek
Copy link
Contributor Author

It works, thank you!

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

2 participants