You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove automatic -loader module name extension #2986
Current behavior:
webpack automatically appends -loader to a module when the first module lookup failed
Expected/desired behavior:
webpack should not append -loader
What is the motivation / use case for changing the behavior?
It can lead to errors that are hard to understand for newcomers. I've seen it a couple of times that webpack tried to resolve the css module as css-loader because people have just configured loader: "css". In combination with npm@3, this can be very confusing as you may have never installed the css module by yourself.
This change would probably require a lot of webpack configs to be adjusted, but since the loader configuration has been changed in webpack@2 anyway, we should include that change as well. As a downside, the config will become a little more verbose because now everyone has to write style-loader!css-loader, but I think the benefit outweighs the downside by far.
Reacted by Tobias Koppers, Mark Finger, J Phani Mahesh, Damiano, Ivaylo Bratoev, Max T., Preco, SEAPUNK, Dariusz Rzepka, Kyle Mathews and 49 more
Reacted by Brandon J. Boone
Reacted by fox and Jimmie Ren
Reacted by fox, Aaron Meese and Martin Quintana
Reacted by fox and Syed Mohammad Muzzammil
Reacted by fox, Bright, kotborealis, Mihail Malo, Martin Quintana and Samir Chugh
@iDams awesome! 👍 @TheLarkInn This would be a change that requires a lot of webpack.configs to be adjusted. But: Since we are changing the way how loaders are configured in webpack 2 anyway, we should put this change into webpack 2.x
Hey, I could use some advice :D
I've started looking into /lib files especially those which seems to be linked to module like ModuleParseHelper.js, RawModule.js, ... Am I in going into the right direction?
Any input on this?
I will keep looking how this is related to the line I removed!
This is exactly why removing this line is a breaking change. You need to adjust the failing test cases, they should use val-loader!... instead of just using val!...
I would like to add that this was a frustrating breaking change that appears to have fairly weak rationale behind it relative to the cost - having to chase around what changed for an hour and filing PRs to fix Webpack plugin projects was not fun.
I apologize for the this @wesleycho. This change is one of many steps that plan to pave the way for overall more consistent and standard config usage.
This was something that would have had to been cherry picked out and then back into master if we tried to avoid it. I will create an issue that will block 2.x release until we have a great error message that will help people migration through this change.
Alternatively we would welcome any suggestions for this as well. Catching the 100x ways to specify loaders has made it very hard to catch and consistently error (which is why we don't have a PR merged for this yet).
Hmm, I expected that resolveLoader.moduleExtensions would work the same as resolve.extensions (used to): and try each appended to the request in order. i.e, it defaulted to moduleExtensions: ['-loader', ''] and would try css-loaderfirst, then css
I suspect the breaking-changeness of this could be walked back in a 2.3+ safely enough by making it work that way, which should only break if someone has some-loader-loader but expected to find some-loader exactly - npms.io isn't great at finding module name patterns, but I couldn't see any such names.
Activity
TheLarkInn commentedon Sep 12, 2016
This makes sense. Its not too much extra work to have someone add "-loader". Explicit.
bebraw commentedon Sep 12, 2016
Yeah, this would be a good change for webpack 2. Less confusion.
amsdamsgram commentedon Sep 15, 2016
Hi, I'm willing to take a look at this if no one is already on it!
TheLarkInn commentedon Sep 15, 2016
Go right ahead.
TheLarkInn commentedon Sep 15, 2016
This would however land after webpack 2.x as it would be a pretty irritating breaking change unless anyone disagrees?
amsdamsgram commentedon Sep 15, 2016
No worries.
Where should I start looking at?
jhnns commentedon Sep 15, 2016
@iDams awesome! 👍
@TheLarkInn This would be a change that requires a lot of webpack.configs to be adjusted. But: Since we are changing the way how loaders are configured in webpack 2 anyway, we should put this change into webpack 2.x
amsdamsgram commentedon Sep 16, 2016
Hey, I could use some advice :D
I've started looking into
/libfiles especially those which seems to be linked to module likeModuleParseHelper.js,RawModule.js, ... Am I in going into the right direction?andreypopp commentedon Sep 16, 2016
@iDams see this line https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsDefaulter.js#L93
amsdamsgram commentedon Sep 16, 2016
@andreypopp thanks!
10 remaining items
jhnns commentedon Oct 4, 2016
This is exactly why removing this line is a breaking change. You need to adjust the failing test cases, they should use
val-loader!...instead of just usingval!...amsdamsgram commentedon Oct 5, 2016
Got it, thanks!
amsdamsgram commentedon Oct 7, 2016
Hey, I submitted a PR.
All tests passed on my local but travis-ci on Linux with node.js 5 failed.

Do you have any advice on how to debug this?
I've seen couple of options, VM, Travis Build, Vagrant or with a docker image.
I'm on OSX so I will probably have to install a VM with Linux.
jhnns commentedon Oct 19, 2016
See #3102 (comment)
Included "-loader" in the name of every loader
Add `-loader` to every loader name
wesleycho commentedon Nov 14, 2016
I would like to add that this was a frustrating breaking change that appears to have fairly weak rationale behind it relative to the cost - having to chase around what changed for an hour and filing PRs to fix Webpack plugin projects was not fun.
TheLarkInn commentedon Nov 14, 2016
I apologize for the this @wesleycho. This change is one of many steps that plan to pave the way for overall more consistent and standard config usage.
This was something that would have had to been cherry picked out and then back into master if we tried to avoid it. I will create an issue that will block 2.x release until we have a great error message that will help people migration through this change.
Alternatively we would welcome any suggestions for this as well. Catching the 100x ways to specify loaders has made it very hard to catch and consistently error (which is why we don't have a PR merged for this yet).
sokra commentedon Nov 14, 2016
Here you are: #3289
simonbuchan commentedon Jan 18, 2017
Hmm, I expected that
resolveLoader.moduleExtensionswould work the same asresolve.extensions(used to): and try each appended to the request in order. i.e, it defaulted tomoduleExtensions: ['-loader', '']and would trycss-loaderfirst, thencssI suspect the breaking-changeness of this could be walked back in a 2.3+ safely enough by making it work that way, which should only break if someone has
some-loader-loaderbut expected to findsome-loaderexactly - npms.io isn't great at finding module name patterns, but I couldn't see any such names.With the change to
resolve.extensionsthough, I'm not sure that it still works that way? E.g. try all the extensions first? https://webpack.js.org/configuration/resolve/ isn't clear on what happens with conflicts.jcrben commentedon Apr 10, 2017
Next time, I suggest that instead of removing something like this in
2.x, put a warning in2.xand remove it in3.x.hzlmn commentedon May 19, 2017
@jcrben It's the way how @postcss do it. Webpack team should learn more about convenient releases from it.
Included "-loader" in the name of every loader