Skip to content
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

improve exclude optimizer #76

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

SuperchupuDev
Copy link
Owner

@SuperchupuDev SuperchupuDev commented Dec 1, 2024

shorter and probably faster implementation 🎉 also improves optimization for patterns that end with **

needs some work, this implementation (and the previous one) don't work well with patterns that wrap / in things like *(src/index.ts). see #76 (comment) disabled optimizations in those cases for now

also closes #79 once the above is solved, and makes tests from #80 work :-)

Copy link

pkg-pr-new bot commented Dec 1, 2024

Open in Stackblitz

npm i https://pkg.pr.new/tinyglobby@76

commit: fe3b342

Co-authored-by: Joachim Viide <[email protected]>
@SuperchupuDev
Copy link
Owner Author

SuperchupuDev commented Jan 17, 2025

while the tests do pass now thanks to the new fdir version fixing excluding symlinks, this implementation doesn't handle patterns that have / inside glob symbols well, for example this test that i haven't pushed:

test('dynamic patterns that include slashes inside parts', async () => {
  const files = await glob({ patterns: ['{.a/a,a}/a.txt'], cwd });
  // files ends up being []
  assert.deepEqual(files.sort(), ['a/a.txt', '.a/a/a.txt']);
});

it's easy to see why it fails but hard to properly fix. other than splitting the parts with picomatch which is easy to do (now done), i'm not sure how to modify the code to properly account for it. there's an option to just replace parts that have / with ** but it should be the last choice as that would just skip optimizations

@benmccann
Copy link
Contributor

Would it help to have tinyglobby expand ['{.a/a,a}/a.txt'] to ['.a/a/a.txt', 'a/a.txt'] as a first step?

@SuperchupuDev
Copy link
Owner Author

maybe but i'm not sure if it's optimal

didn't want to do this, but this pr is important and a release is being delayed too much. thankfully, it seems like almost no one uses patterns like that. any optimizations here are welcome
@SuperchupuDev SuperchupuDev marked this pull request as ready for review January 29, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

common path algorithm calculates parts wrong with / inside part
2 participants