Skip to content

replace micromatch with picomatch#1953

Merged
Andarist merged 5 commits intochangesets:nextfrom
beeequeue:match
May 4, 2026
Merged

replace micromatch with picomatch#1953
Andarist merged 5 commits intochangesets:nextfrom
beeequeue:match

Conversation

@beeequeue
Copy link
Copy Markdown

currently stuck on the default config no longer parsing

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: a8e32c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@changesets/config Patch
@changesets/git Patch
@changesets/apply-release-plan Patch
@changesets/cli Patch
@changesets/get-release-plan Patch
@changesets/read Patch
@changesets/release-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 4, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​picomatch@​4.0.31001007484100
Addeddotenv@​16.6.19910010094100

View full report

} from "@changesets/types";
import { getPackages } from "@manypkg/get-packages";
import micromatch from "micromatch";
import picomatch from "picomatch";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

@beeequeue beeequeue May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picomatch wayyyy faster iirc as the builtins use minimatch

but i don't have any benchmarks saved so i'll try to find or make some

i also mentioned this on bsky recently :^)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use this instead so we don't touch the fs: https://nodejs.org/api/path.html#pathmatchesglobpath-pattern

Open to trying it though but we still kinda need a wrapper to handle array of files and patterns.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to know the benchmark results. However, that wouldn't really be a bottleneck in the case of Changesets - so we could just favor less dependencies over a more performans library here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.99%. Comparing base (ed6728c) to head (a8e32c2).
⚠️ Report is 1 commits behind head on next.

Files with missing lines Patch % Lines
packages/git/src/index.ts 78.57% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1953      +/-   ##
==========================================
+ Coverage   81.90%   81.99%   +0.09%     
==========================================
  Files          54       54              
  Lines        2432     2461      +29     
  Branches      706      718      +12     
==========================================
+ Hits         1992     2018      +26     
- Misses        398      400       +2     
- Partials       42       43       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bluwy
Copy link
Copy Markdown
Member

bluwy commented May 4, 2026

I updated getUnmatchedPatterns that wasn't migrated quite right, and I updated the matching to handle this specific behavior from micromatch:

import picomatch from 'picomatch'
import micromatch from 'micromatch'

const pkgs = ['pkg-a', 'pkg-b', '@scope/pkg-c', '@scope/pkg-d']
const globs = ['pkg-*', '!pkg-b', '@scope/*']

const matcher = picomatch(globs)
console.log('picomatch:', pkgs.filter((pkg) => matcher(pkg)))
// => [ 'pkg-a', 'pkg-b', '@scope/pkg-c', '@scope/pkg-d' ]

console.log('micromatch:', micromatch(pkgs, globs))
// => [ 'pkg-a', '@scope/pkg-c', '@scope/pkg-d' ]

The negation is order-sensitive. picomatch simply returns true if any pattern returns true.

@Andarist
Copy link
Copy Markdown
Member

Andarist commented May 4, 2026

Hm, shouldn't we inherit picomatch semantics though? We do mention what matcher library gets used under the hood - so people can reason about their glob patterns etc. Diverging from that could feel surprising.

@beeequeue
Copy link
Copy Markdown
Author

i would prefer leaving the behavior to picomatch, less code for us to worry about

@bluwy
Copy link
Copy Markdown
Member

bluwy commented May 4, 2026

If we leave it entirely to picomatch, they'd have to craft every pattern to not include it, like "pkg-!(a)" instead to get the negation pattern work like before. I feel like this will be quite difficult to migrate though and not worth it. For reference, here's how picomatch implements array support.

Should we consider documenting instead? I also think the link to picomatch also mostly refers to its pattern syntax than the array matching behaviour.

@Andarist
Copy link
Copy Markdown
Member

Andarist commented May 4, 2026

If we'd decide to use the builtin node API then this discussion would become obsolete :p I'm fine either way, so I'll leave you both to decide if we should use the node API or picomatch.

@bluwy
Copy link
Copy Markdown
Member

bluwy commented May 4, 2026

If path.matchesGlob works and is compatible, I think we should use it. I'm just a bit lazy to check and update it 😄

@bluwy bluwy marked this pull request as ready for review May 4, 2026 13:50
@Andarist Andarist merged commit b9407b3 into changesets:next May 4, 2026
10 checks passed
@beeequeue beeequeue added this to the v3 milestone May 4, 2026
@beeequeue beeequeue deleted the match branch May 4, 2026 14:53
@github-actions github-actions Bot mentioned this pull request May 4, 2026
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.

3 participants