-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: add matchesGlob
export
#195
Conversation
I would suggest that we omit implementing this feature due to the increase in size. |
other than node:path compatiblity, Alternative way to use glob in other projects is another dependency and both micro/picomatch are way bigger in all terms, cjs and even non treeshakable. pathe is only standard place i could think we can ship optimized glob util. |
did you come across/evaluate zeptomatch? another option might be refactoring and including in glob-native? |
could we add it as a dependency rather than bundling it? |
Amazing suggestion. Brace compatibility is limited but I think bundle size worth it. (bundled version is dual format, lazy eval similar to Node and much smaller) packagephobia |
Not bundling does mean it can deduplicate across other deps though, which I would prefer in honesty. (if even one other dep uses zepto then we lose any size benefit) |
It is a common practice i do within unjs (consola, jiti, confbox, jimp-compact. …) when there is benefit it is not an exception here. And i prefer we do this here too (there are clear stats it is not preference only btw). Without bundling we could even use minimatch end result is not much different! Vite, Next.js and Nuxi also do bundling btw for similar reasons. |
external dep is also not lazy evaluatable in (non async) ESM context, thats a runtime overhead it imposes for basically every pathe consumer even if they don’t use glob functionality. |
unless necessary I think it's a negative to inline or bundle dependencies that could otherwise be deduped. vite and nextjs are frameworks rather than libraries, and nuxi is single file executable. (all three are special cases for me). I would cast a vote against it, particularly given there is no essential reason to add this utility to pathe rather than just depending on zeptomatch in any project that needs the functionality. |
Appreciate your time and sharing feedback ❤️ Adopting zeptomatch was a really great suggestion. I understand the difference between libraries and frameworks, I made some + unjs tools are their building blocks :) consola, jiti and confbox are obvious examples (of libs) that bundling sub-deps helped (I let you to calculate how much traffic and disk space/access over years they saved and judge for them). So far, non of zeptomatch dependents overlap with our ecosystem ( For this PR, bundling benefits are:
(externalization has an opposite effect!)
Glob is an essential functionality in many usecases -- common enough that Node.js also added it to the core. Using |
personally I don't consider zero dependency to be a benefit for a library like pathe, if we achieve it by inlining those dependencies (though I do see your metrics and understand the slight benefit) I would rather use another purpose built library like zepto (or something else), and advocate using it across ecosystem where required rather than suggesting people use our inlined version instead (this is a philosophical point as well as one about deduplication/total size) if there is any problem with that library, such as in its packaging, I'm sure the maintainer would be delighted to improve it |
I have provided as much reasons and explanations as could above that judges the decision by facts and hope even if today you can't agree, see it better in the future. |
no worries. I appreciate you valued my opinion, which remains that we should not inline this from another library. (not inlining it does not stop pathe having canonical behaviour or prevent us from swapping implementation later) I am not attempting to block you, just passing on my considered opinion 🙏 |
Inlining in this case has clear benefits over externalization (#195 (comment)) and dedup point is not relevant (at last today) -- nothing philosophical. If we come to the fact that externalization has more benefits at some point, I'm 💯 open to changing dep as external (and we actually did switch between inline<>external in several cases before in UnJS) Advising to depend on |
i think there is a misunderstanding. i mean deduping zeptomatch itself, not its dependencies |
I pointed to Dependents page not Dependencies. |
oh, my misunderstanding. it may change in future as it is adopted |
resolves #182
Add
matchesGlob
export to match latestnode:path
and stay as drop-in replacement (docs)The implementation uses vendored+minified version of
minimatch to be the same as Node.jszeptomatch. (ESM + CJS + tree-shakable + lazy evaluated)node_modules/.pnpm/zeptomatch@2.0.0
+236K / +37 files packagephobiaDiff:+ 19.4 kB
(packed esm+cjs) /+43.1 kB
(unpacked esm+cjs) /+0
filesComparison.pnpm/minimatch@10.0.1
:+ 572 kB
/+60
files