filer icon indicating copy to clipboard operation
filer copied to clipboard

Investigate switching from minimatch to picomatch

Open humphd opened this issue 6 years ago • 2 comments

We use minimatch in our implementation of sh.find() to match glob patterns. Let's see if we can switch to picomatch, which is smaller, and has zero dependencies.

minimatch is ~7K in our bundle:

node_modules/minimatch/minimatch.js       7.32 KB     11ms

It would be good to see if that goes down with picomatch.

NOTE: picomatch uses the builtin path module, so fixing #597 would help here too.

humphd avatar Dec 02 '18 15:12 humphd

Comparison of minimatch and picomatch sizes and deps.

First minimatch

dist/minimatch.js                                                                               14.56 KB    611ms
├── minimatch.js                                                                                 7.31 KB     17ms
├── ../../../usr/local/lib/node_modules/parcel-bundler/node_modules/process/browser.js           2.27 KB    231ms
├── ../../../usr/local/lib/node_modules/parcel-bundler/node_modules/path-browserify/index.js     2.09 KB      2ms
├── node_modules/brace-expansion/index.js                                                        2.06 KB    176ms
├── node_modules/balanced-match/index.js                                                           601 B    116ms
└── node_modules/concat-map/index.js                                                               259 B     65ms

And picomatch:

dist/index.js                                19.84 KB    17.55s
├── lib/parse.js                              9.62 KB     681ms
├── lib/picomatch.js                          3.18 KB     758ms
├── node_modules/process/browser.js           2.63 KB     200ms
├── lib/scan.js                               2.13 KB     453ms
├── node_modules/path-browserify/index.js      2.1 KB     166ms
└── index.js                                    116 B    16.08s

humphd avatar Dec 04 '18 03:12 humphd

Filed a bug in picomatch to discuss, and it looks like we can't do much to make it smaller than it is (4.7K minified and gzipped vs. 4.1K for minimatch), https://github.com/micromatch/picomatch/issues/6

I'm still tempted to consider it, since it has no dependencies.

humphd avatar Dec 04 '18 18:12 humphd