@@ -291,28 +291,10 @@ export async function globWithGitIgnore(
291291 }
292292 }
293293
294- // Match every gitignore-derived pattern through a single reused `ignore`
295- // instance instead of handing the whole set to fast-glob's native `ignore`
296- // option. fast-glob re-compiles and re-tests its entire ignore array inside
297- // each directory scan (`node::fs::AfterScanDir`), so a large monorepo whose
298- // nested `.gitignore` files union to tens of thousands of patterns aborts with
299- // `CALL_AND_RETRY_LAST … heap out of memory`. Raising `--max-old-space-size`
300- // does not reliably help: much of the cost is regex executable code in V8 code
301- // space rather than the data heap. The `ignore` package compiles each rule
302- // once and memoizes it, so the cost scales with the pattern count rather than
303- // being multiplied by the number of directories walked. fast-glob
304- // keeps only the small, bounded set it needs to PRUNE directories during the
305- // walk (`defaultIgnore`, which already excludes node_modules and .git, plus
306- // the anchored CLI minimatch ignores); the high-cardinality gitignore set is
307- // applied per streamed entry by `ig` below. The `ignore` package also honors
308- // negated re-includes, which fast-glob, globby, and tinyglobby cannot express.
309- // The negated-pattern path already worked this way; routing both cases through
310- // it removes the asymmetry that left the common, non-negated case crashing on
311- // large repos.
312- // Match fast-glob's case sensitivity (its `caseSensitiveMatch` defaults to
313- // true) so routing the non-negated path through the `ignore` package does not
314- // silently start matching case-insensitively, which is the `ignore` package's
315- // own default.
294+ // Match the high-cardinality gitignore set through one reused `ignore`
295+ // instance, not fast-glob's `ignore` (which recompiles its whole array per
296+ // directory scan and OOMs on tens of thousands of patterns); fast-glob keeps
297+ // only the bounded prune set. `ignorecase` tracks fast-glob's default.
316298 const ig = ignore ( {
317299 ignorecase : additionalOptions . caseSensitiveMatch === false ,
318300 } ) . add ( [ ...ignores ] )
@@ -343,11 +325,10 @@ export async function globWithGitIgnore(
343325 globOptions ,
344326 ) as AsyncIterable < string >
345327 for await ( const p of stream ) {
346- // Note: the input files must be INSIDE the cwd. If you get strange looking
347- // relative path errors here, most likely your path is outside the given cwd.
348328 // Normalize to POSIX separators: the `ignore` patterns are forward-slash
349- // anchored (see ignoreFileLinesToGlobPatterns), so a Windows backslash path
350- // from path.relative would never match them.
329+ // anchored (ignoreFileLinesToGlobPatterns), so a Windows backslash path from
330+ // path.relative would never match. Input must be inside cwd, else
331+ // path.relative returns an odd `..`-prefixed relative path.
351332 const relPath = normalizePath (
352333 globOptions . absolute ? path . relative ( cwd , p ) : p ,
353334 )
0 commit comments