Remove automatic -loader module name extension

I’m submitting a feature request

Webpack version:
2.x

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.

Author: Fantashit

5 thoughts on “Remove automatic -loader module name extension

  1. If there are already failing tests on master, you can ignore them. Just check if your changes don’t break additional tests.

    @sokra failing tests on the main branch make contributing a lot harder. We should try to keep failing tests only on feature branches. Have we ever talked about using git flow? 🙂

  2. 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.

  3. 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).

  4. Next time, I suggest that instead of removing something like this in 2.x, put a warning in 2.x and remove it in 3.x.

Comments are closed.