oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.13k stars 2.67k forks source link

Support `ignores` in Bun.Glob options #8182

Open kmartinezmedia opened 8 months ago

kmartinezmedia commented 8 months ago

What is the problem this feature would solve?

The pattern matching support isn't extensive enough. Currently I'm having to do the following

const COMPONENTS = Array.from(
  new Glob(`**/*.tsx`).scanSync({ cwd: componentsDir, dot: false, absolute: true }),
).filter((name) => !['.test.', '.stories.'].includes(name));

What is the feature you are proposing to solve the problem?

Add support for ignores option like fast-glob

What alternatives have you considered?

Expanding glob patterns with more extensive negative lookups or the like still isn't best devx experience / readable

paperdave commented 8 months ago

I wanted this exact feature a couple of days ago. While working on the tooling for #8166, this is a feature I wanted but it would be too slow to filter the glob after matching it, so I had to use lame readdirRecursive implementations that shouldn't be written anymore.

mathiasrw commented 3 weeks ago

While we wait for the perfect solution: Would it work to join include globs with negated ignore globs?

Bun.Glob(`{${[...include, ...exclude.map(v=> '!'+v)].join(',')}}`). // untested, just an idea