Conversation
|
The matcher returned by getMatcher rebuilt the glob string and compiled a new picomatch matcher inside every test() call. Compile it when the filter is created and only recompile if the working directory has changed since, so relative patterns still resolve against the cwd at call time.
Cherry
force-pushed
the
perf/pluginutils-createfilter-compile-once
branch
from
September 28, 2026 02:26
80c18bc to
fdaa3f1
Compare
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.
The matcher returned by getMatcher rebuilt the glob string and compiled a new picomatch matcher inside every test() call. Compile it once when the filter is created instead, and add a test that the number of picomatch compilations does not grow with the number of filter calls.
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:
Picks up similar work in #1921, which was closed as abandoned.
Description
Discovered this minor improvement while benchmarking a larger project internally.
createFilter's string matchers rebuilt the glob and compiled a new picomatch matcher inside everytest()call, so every filtered id paid the full compile cost for every pattern. This compiles each pattern once when the filter is created.With a realistic include/exclude pair (
src/**/*.ts,src/**/*.vue/src/storybook/**/*,src/**/*.stories.ts) over ~670 real paths, a filter call went from ~22.6碌s to ~1.1碌s, with identical results for every path.