tiny-glob icon indicating copy to clipboard operation
tiny-glob copied to clipboard

How to ignore searching inside `node_modules`

Open vjpr opened this issue 4 years ago • 5 comments

Using !(node_modules)/**/package.json still seems to search within node_modules...or at least its still very slow compared to every other library I'm testing.

vjpr avatar Oct 21 '21 00:10 vjpr

I addresed a similar use case in QUnit sometime ago using picomatch incombination with a recursive fs.readdir call (for gathering files), and node-watch for performant watching over an entire project (and exclude node_modules):

https://github.com/qunitjs/qunit/commit/b7fb112d61dd9a03c69e32c9da204defb1b166c1

I switched the "gather files" part from picomatch to tiny-glob in the above change, because I found it to make the code simpler (and probably faster too). If you need to gather all files but not enter node_modules, I would restructured the call so as to invoke glob separately for the top-level directories and skip node_modules at that level, and use glob only for recursing within each of the top-level directories.

Krinkle avatar Oct 22 '21 01:10 Krinkle

In a monorepo this won't work - there will be 100s of nested node_modules. tiny-glob needs to have a way to not enter dirs.

vjpr avatar Oct 22 '21 03:10 vjpr

Agree, without this feature, I can't adopt tiny-glob, which I was planning to do for storybook.

IanVS avatar Sep 29 '22 15:09 IanVS

It's probably easier to add an exclude option to prevent traversing of unwanted directories.

see #74 see How to exclude directory from reading? for fast-glob

chdh avatar Dec 28 '22 02:12 chdh

any update?

techsin avatar May 02 '24 14:05 techsin