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

refactor: replace globby with faster alternative #1158

Merged
merged 2 commits into from
Jul 19, 2024

Conversation

SuperchupuDev
Copy link
Contributor

@SuperchupuDev SuperchupuDev commented Jul 17, 2024

globby has a count of 23 subdependencies, which is far from ideal for something as simple as globbing. This PR switches to a lighter and faster alternative using fdir and picomatch. They have both a total of zero (0) subdependencies, making this not just a faster approach, but also one that's way lighter.

This makes tsup go from 102 subdependencies down to just 88.

Note: The patterns at

tsup/src/utils.ts

Lines 69 to 77 in 57a372b

const matchPatterns: string[] = []
const ignorePatterns: string[] = []
for (const pattern of patterns) {
if (pattern.startsWith('!') && pattern[1] !== '(') {
ignorePatterns.push(pattern.slice(1))
} else {
matchPatterns.push(pattern)
}
}
are filtered this way to properly match what globby (or more specifically, fast-glob which is used by globby) does. It has some behavior around negated patterns no other globbing library has.

Relevant prior work: dotenvx/dotenvx#278

Copy link

codesandbox bot commented Jul 17, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Jul 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tsup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 19, 2024 2:53pm

@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Jul 17, 2024

tests are failing on windows but not on linux...weird

@sxzz
Copy link
Collaborator

sxzz commented Jul 19, 2024

I think we can use fdir and picomatch to create a new library for lightweight glob, enhancing maintainability.

@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Jul 19, 2024

the implementation here isnt big really, there's a pr in fdir to add a glob function method though (requiring a matcher function) that maybe could be used in the future. i dont really see a need of making it a lib if sometimes fdir is called in a way picomatch (therefore globbing) isnt even needed

@sxzz sxzz force-pushed the refactor/globby-but-fast branch from 3e610e7 to ff3acc0 Compare July 19, 2024 14:53
@sxzz sxzz merged commit 0f0b4b2 into egoist:dev Jul 19, 2024
9 checks passed
@SuperchupuDev SuperchupuDev deleted the refactor/globby-but-fast branch July 19, 2024 15:05
Copy link
Contributor

🎉 This issue has been resolved in version 8.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lenovouser
Copy link

I am getting this now after upgrading to 8.2.1

Screenshot 2024-07-21 at 11 47 51

@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Jul 21, 2024

i am aware, when conflicts were solved, it looks like picomatch was updated to v4 which fdir's package.json doesn't allow. to fix this tsup must downgrade to picomatch v3 or fdir must release a new version which contains a fix i submitted a few days ago thecodrr/fdir#101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants