next.js
dd7fed07 - Fork the globset strategy for turbopack (#79333)

Commit
1 year ago
Fork the globset strategy for turbopack (#79333) ## What After discussion with [upstream](https://github.com/BurntSushi/ripgrep/issues/3049) it was determined that upstreaming a function like `can_skip_directory` wasn't aligned. It turns out the needs of ripgrep and ours are somewhat divergent. Instead they encouraged me to just fork and modify which is what we do here. This copies the glob->regex translation logic and drops much of the other functionality that is optimized for large sets of globs. Then I have added our `can_skip_directory` function following a similar pattern. ## Why This approach allows us to easily support for character ranges (e.g. `[A-Za-z0-9_-]`) and improves performance. I also suspect that this will be easier to maintain as debugging the generated regular expressions should be quite straightforward. ## Alternatives We could just adopt globset directly as proposed in #79116 however we would lose the ability to skip directories during traversal which can reduce the cost of setting up turbotasks dependencies and directory watchers. The other alternative that i pursued was a direct NFA implementation (see #78976). This would be more memory efficient than regular expressions since both queries can share the same NFA, but the regex crate is much faster and better maintained. If memory overhead becomes a concern we can configure the regexes to use less, however, i suspect many of our generated regexes will be quite simple and thus generate small automata. Closes PACK-4401 Fixes #72196
Author
Parents
Loading