Repository navigation
Conversation
|
For maintainers only:
|
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
|
It looks like this Pull Request doesn't include enough test cases (based on Code Coverage analysis of the PR diff). A PR need to be covered by tests if you add a new feature (we want to make sure that your feature is working) or if you fix a bug (we want to make sure that we don't run into a regression in future). @Lyrkan Please check if this is appliable to your PR and if you can add more test cases. Read the test readme for details how to write test cases. |
|
"Windows node-12" check seems to be failing because of an unrelated timeout, and the code coverage issues are mainly due to already existing (and not covered) lines that were changed by Prettier. |
|
I thought about that again, can came to the conclusion that it's probably a bad idea to have such a method in the loader. This would probably lead to this call will be added to too many loader just in case the loader is used on some non-js file. When multiple loaders are chained and set different module types this is getting a little bit weird, since only the last one is respected. It increases the coupling from loader to webpack and webpack version. Instead I think most problems can be solved by remaining the user to specify a |
|
Hi @sokra, I agree with your concerns, but shouldn't there still be a way to force that kind of thing properly in some cases? One use we would have for that method in Webpack Encore is that we created a custom loader which is only used in some Those are done internally so we do know that the loader will always be the last one in the chain but since currently there is no way (AFAIK) to set the type when using the inline syntax we had to resort to accessing/modifying |
While you probably should avoid inline syntax anyway, there is a way. You should use the inline match resource for this case. e.g. for a loader converting json to js: import "./file.json.js!=!json-to-js-loader!./file.json"This will interpret the result of the loader like it was in a |
Yeah, we're doing some weird things in order to copy files.. the It's very hackish but surprisingly it works quite well (apart from people reporting that they couldn't copy JSON files). I didn't think about the inline match resource though, I guess it should work, thanks for the tip :) Edit: Actually I'm not sure it'll work in a |
should work fine. |
I actually meant Anyways, if this is possible in other "normal" use cases maybe you're right and this PR isn't needed after all, feel free to close it :) |
Btw the quality of the PR is great. I just don't want to introduce a feature which affects the overall experience badly. |
This PR adds a
setModuleType(type)method to the Loader interface that allows to change the type, parser and generator of the related module (closes #7057).For instance:
What kind of change does this PR introduce?
Feature
Did you add tests for your changes?
Yes, let me know if I need to add more.
Does this PR introduce a breaking change?
No
What needs to be documented once your changes are merged?
The new method should be added to the following page: https://webpack.js.org/api/loaders/