terkelg / tiny-glob

Super tiny and ~350% faster alternative to node-glob
MIT License
853 stars 26 forks source link

How to ignore searching inside `node_modules` #79

Open vjpr opened 2 years ago

vjpr commented 2 years ago

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.

Krinkle commented 2 years ago

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.

vjpr commented 2 years ago

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.

IanVS commented 1 year ago

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

chdh commented 1 year ago

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

techsin commented 4 months ago

any update?