-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potentially the biggest performance improvement that can be done #46
Comments
Knip does something similar, but just for
The key is to have functionality like this |
Scratch that, I mixed up Still, the |
an initial implementation has been merged in #69! the code can be improved further though, which is what i'll try to do before a new release |
current status of this issue: while an initial implementation was merged (and still not released yet!), it broke some use cases (#80). #76 was opened, which not only fixes this use case but it also works better at optimizing. however, there is still one use case that breaks in both: using |
I'm not even sure how to approach the problem, but implementing this means that all of the weird patterns that currently avoid all optimizations would be really optimized along with literally everything else.
By default,
fdir
crawls all subdirectories and files of a root, which can result in extra processing work that's not necessary, harming performance.tinyglobby
tries to apply some optimizations by inferring a common root.fdir
exposes aexclude
function that can be used to exclude directories from crawling. It's being currently used on theignore
patterns to... not crawl those ignored patterns?What if, we took the matching patterns (basically the patterns that aren't meant to be ignored), we did some weird transformations to them, and used them in the
exclude
matcher?For example, let's say we have the following usage:
with the following file structure:
Basically, we need a picomatch matcher that returns
true
for every directory that we don't want to crawl, in this casenode_modules
,plugins
,scripts/utils
, andsrc/other
. This could be implemented with the following picomatch usage:Great! It now only crawls the directories needed (hopefully, I haven't checked). Now the question is how to implement something that converts
['src/files/index.ts', 'scripts/*.ts'
into['src/files', 'scripts/*/**']
, which is the whole point of this issue. If we figure it out,tinyglobby
should be nearly as fast as possible.Some notes:
<pattern>/**
patterns work. It not only matches subdirectories of<pattern>
, but it also matches<pattern>
itself. this is why the second processed pattern in the example isn'tscripts/**
, as that would matchscripts
makingfdir
not crawl it.normalizePattern
function, so that we don't need to loop through the patterns extra times.The text was updated successfully, but these errors were encountered: