Add matchResource feature (for loaders)#7462
Merged
Merged
Conversation
Contributor
|
For maintainers only:
|
Match rules with custom resource name Also use this name as rule.issuer or splitChunks test Show nicely in stats
44b59d7 to
530e1fb
Compare
Contributor
|
This is awesome. Will allow us to get rid of |
Contributor
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
Contributor
|
I've created an issue to document this in webpack/webpack.js.org. |
Contributor
|
Exciting! @sokra is this going to land in the next minor? |
Contributor
|
The way you can share memory in WASM looks interesting, I haven't really looked into yet! I'll test it during the week. Thanks for the ping @sokra |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Match rules with custom resource name
Also use this name as rule.issuer or splitChunks test
Show nicely in stats
cc @xtuc (holyc-loader)
cc @yyx990803 (vue-loader)
This is interesting for you.
What kind of change does this PR introduce?
feature
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
For loader authors:
A new inline request syntax is available. Prefixing
<match-resource>!=!to a request will set thematchResourcefor this request. (A relativematchResourcewill resolve relative to the current context of the containing module.)When a
matchResourceis set, it will be used to match with themodule.rulesinstead of the original resource. This can be useful if further loaders should be applied to the resource, or if the module type need to be changed. It's also displayed in the stats and used for matchingRule.issuerandtestinsplitChunks.Example: A loader extracts styles from comments in javascript files.
A loader could transform the file into the following file and use the
matchResourceto apply the user-specified css processing rules:This will add a dependency to
extract-style-loader/getStyles!./file.jsand threat the result asfile.js.css. Becausemodule.ruleshas a rule matching/\.css$/it will apply to this dependency.