Skip to content

Remove automatic -loader module name extension #2986

Closed

Description

@jhnns

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.

Activity

  1. added
    rfc
    on Sep 12, 2016
  2. self-assigned this
    on Sep 12, 2016
  3. TheLarkInn commented on Sep 12, 2016

    @TheLarkInn
    Member

    This makes sense. Its not too much extra work to have someone add "-loader". Explicit.

  4. bebraw commented on Sep 12, 2016

    @bebraw
    Contributor

    Yeah, this would be a good change for webpack 2. Less confusion.

  5. added this to the 2.1-RC Blocking milestone on Sep 14, 2016
  6. amsdamsgram commented on Sep 15, 2016

    @amsdamsgram

    Hi, I'm willing to take a look at this if no one is already on it!

  7. TheLarkInn commented on Sep 15, 2016

    @TheLarkInn
    Member

    Go right ahead.

  8. TheLarkInn commented on Sep 15, 2016

    @TheLarkInn
    Member

    This would however land after webpack 2.x as it would be a pretty irritating breaking change unless anyone disagrees?

  9. amsdamsgram commented on Sep 15, 2016

    @amsdamsgram

    No worries.
    Where should I start looking at?

  10. jhnns commented on Sep 15, 2016

    @jhnns
    ContributorAuthor

    @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

  11. amsdamsgram commented on Sep 16, 2016

    @amsdamsgram

    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?

  12. andreypopp commented on Sep 16, 2016

    @andreypopp
    Contributor
  13. amsdamsgram commented on Sep 16, 2016

    @amsdamsgram

    @andreypopp thanks!

  14. 10 remaining items

  15. jhnns commented on Oct 4, 2016

    @jhnns
    ContributorAuthor

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

  16. amsdamsgram commented on Oct 5, 2016

    @amsdamsgram

    Got it, thanks!

  17. amsdamsgram commented on Oct 7, 2016

    @amsdamsgram

    Hey, I submitted a PR.

    All tests passed on my local but travis-ci on Linux with node.js 5 failed.
    capture d ecran 2016-10-07 a 10 28 44

    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.

  18. jhnns commented on Oct 19, 2016

    @jhnns
    ContributorAuthor
  19. added a commit that references this issue on Oct 25, 2016
  20. wesleycho commented on Nov 14, 2016

    @wesleycho

    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.

  21. TheLarkInn commented on Nov 14, 2016

    @TheLarkInn
    Member

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

  22. sokra commented on Nov 14, 2016

    @sokra
    Member

    Here you are: #3289

  23. simonbuchan commented on Jan 18, 2017

    @simonbuchan

    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-loader first, 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.

    With the change to resolve.extensions though, 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.

  24. jcrben commented on Apr 10, 2017

    @jcrben

    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.

  25. hzlmn commented on May 19, 2017

    @hzlmn

    @jcrben It's the way how @postcss do it. Webpack team should learn more about convenient releases from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

rfc

Type

No type

Fields

Priority

None yet

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions