fix(pluginutils): only normalize/parse patterns once in createFilter#1921
fix(pluginutils): only normalize/parse patterns once in createFilter#1921lazka wants to merge 1 commit intorollup:masterfrom
Conversation
When passing patterns to createFilter() it would normalize and parse the patterns on every call to the returned filter function. Just do it once at the start instead.
shellscape
left a comment
There was a problem hiding this comment.
Thanks for the PR. Could you please add a test that performs multiple calls to getMatcher in succession, and add the PR number in the test description? That will help protect against future possible regressions.
|
Thanks for the review. Sadly I don't quite understand what type of test you have in mind. Do you want me to move getMatcher to the module level and export it, and then test it? Though it still behaves the same, so there is no way to test the behaviour change. Adding a spy on picomatch would makes sense, but I couldn't find a way to do that. |
|
No worries. Your PR is changing the code so that instead of creating the matcher on every invocation of Changes like this one are very susceptible to regressing in a project like this. We use tests to prevent that from happening. |
Rollup Plugin Name:
pluginutilsThis PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
When passing patterns to createFilter() it would normalize and parse the patterns on every call to the returned filter function.
Just do it once at the start instead.
Something I've noticed while working on #1916.