Skip to content

Conversation

@SuperchupuDev
Copy link
Owner

@SuperchupuDev SuperchupuDev commented Aug 12, 2024

Current Status

unsure if it's needed, will only merge if i see actual usecases in the wild that break without this.

if you need this, please let me know!


kinda hacky, but i can't think of anything else. has a notable performance hit if patterns start with ../ unless ignore options are better configured by the user

imagine you do the following:

glob(['../b/*.ts', '*.ts'], {
  cwd: 'users/me/projects/a'
});

// ['../b/a.ts', 'a.ts']

where the projects directory contains a/a.ts and b/a.ts, in addition to a node_modules folder bigger than god knows what.

in this case, tinyglobby infers a common root of users/me/projects, and it will start crawling every file under that root. this includes everything inside node_modules.

as such, it does some extra crawling that can make the whole thing potentially very slow. one solution for this would be for the user to manually ignore everything they don't want:

glob(['../b/*.ts', '*.ts'], {
  cwd: 'users/me/projects/a',
  ignore: ['../node_modules/**']
});

// ['../b/a.ts', 'a.ts']

this makes it fast again. thoughts?

@SuperchupuDev
Copy link
Owner Author

someone's usecase is indeed breaking without this

unocss/unocss#4094 (comment)

@SuperchupuDev SuperchupuDev merged commit 2f36404 into main Aug 22, 2024
@SuperchupuDev SuperchupuDev deleted the leading-parent-directory branch August 22, 2024 20:32
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.

2 participants