Skip to content

Replace fast-glob with tinyglobby#29

Merged
KayleeWilliams merged 2 commits into
mainfrom
kaylee/replace-fast-glob-with-tinyglobby
May 11, 2026
Merged

Replace fast-glob with tinyglobby#29
KayleeWilliams merged 2 commits into
mainfrom
kaylee/replace-fast-glob-with-tinyglobby

Conversation

@KayleeWilliams
Copy link
Copy Markdown
Collaborator

Summary

Drop-in swap of fast-globtinyglobby per the e18e replacement guide. Affects 5 call sites in packages/leadtype and evals/.

The shape of every call site is preserved by aliasing the named export at the import:

- import fg from "fast-glob";
+ import { glob as fg } from "tinyglobby";

All options used in this repo (cwd, absolute, onlyFiles, ignore, dot, followSymbolicLinks) carry over with identical results.

Why

Supply chain shrink, runtime unchanged. Benchmarks of all six call-site patterns against docs/, packages/, and a synthetic ~600-file node_modules/ corpus (300 iterations after warm-up):

Scenario fast-glob tinyglobby
convert.ts**/*.mdx in docs/ 0.11 ms 0.09 ms (1.21×)
generate.ts inferGroups — **/*.mdx 0.09 ms 0.08 ms (1.13×)
generate.ts hasFilters — **/*.mdx + exclude 0.09 ms 0.08 ms (1.12×)
lint/runner.ts**/*.ts(x) + ignore over packages/ 0.28 ms 0.26 ms (1.09×)
evals/tools.ts grep — **/* over node_modules (~600 files) 0.87 ms 0.87 ms (tied)
evals/tools.ts glob — **/*.d.ts over node_modules 0.88 ms 0.87 ms (tied)

Runtime is a wash — every call site touches small directories so neither library dominates. The real win is dependency footprint:

packages size on disk
fast-glob closure 16 ~1.2 MB
tinyglobby closure 3 ~240 KB

13 fewer transitive deps (drops @nodelib/*, braces, micromatch, fastq, merge2, queue-microtask, run-parallel, reusify, glob-parent, fill-range, is-extglob, is-glob, is-number, to-regex-range). picomatch is shared between both.

Test plan

  • bun x ultracite check — clean
  • bun run check-types — passes
  • bun run test in packages/leadtype — 146/146 pass
  • bun run test in evals — 17/17 pass
  • Result-set parity verified across all 6 call patterns in benchmark

🤖 Generated with Claude Code

Drop-in swap of the globbing dep. Cuts 13 transitive packages and
~80% of installed bytes (1.2 MB → 240 KB) for the same call sites
in lint, convert, generate, and the evals tool harness. All existing
glob options (absolute, onlyFiles, ignore, dot, followSymbolicLinks,
cwd) carry over with identical results across the repo's call sites.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f0052abc-1fdb-4025-8843-f18a98062551

📥 Commits

Reviewing files that changed from the base of the PR and between cf350d6 and 70603c7.

📒 Files selected for processing (4)
  • evals/lib/tools.ts
  • packages/leadtype/src/cli.test.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/lint/runner.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use const assertions (as const) for immutable values and literal types
Leverage TypeScript's type narrowing instead of type assertions

Files:

  • packages/leadtype/src/lint/runner.ts
  • packages/leadtype/src/cli/generate.ts
  • evals/lib/tools.ts
  • packages/leadtype/src/cli.test.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use meaningful variable names instead of magic numbers - extract constants with descriptive names
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, never var
Always await promises in async functions - don't forget to use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors
Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully - don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Don't use eval() or assign directly to document.cookie
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports
Use descriptive names for functions, variables, and types for meaningful naming
Add comments for complex logic, but prefer self-documenting code

Files:

  • packages/leadtype/src/lint/runner.ts
  • packages/leadtype/src/cli/generate.ts
  • evals/lib/tools.ts
  • packages/leadtype/src/cli.test.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.{js,ts,jsx,tsx}: Write assertions inside it() or test() blocks
Avoid done callbacks in async tests - use async/await instead
Don't use .only or .skip in committed code
Keep test suites reasonably flat - avoid excessive describe nesting

Files:

  • packages/leadtype/src/cli.test.ts
🔇 Additional comments (4)
evals/lib/tools.ts (1)

5-5: Good semantic-preserving tinyglobby migration.

Aliasing to fg keeps call-site shape stable, and expandDirectories: false correctly prevents bare-directory auto-expansion for agent-provided patterns.

Also applies to: 238-241

packages/leadtype/src/lint/runner.ts (1)

7-7: Nice compatibility guard in the lint glob wrapper.

The import swap is clean, and disabling directory expansion here preserves prior matching behavior while keeping user-supplied ignore handling intact.

Also applies to: 100-103

packages/leadtype/src/cli/generate.ts (1)

7-7: Correct fix for include-filter parity.

Adding expandDirectories: false on the filtered glob path is the right guard to keep --include <bare-dir> behavior consistent with previous semantics.

Also applies to: 436-446

packages/leadtype/src/cli.test.ts (1)

6-6: Strong regression coverage for bare-directory include behavior.

This test captures the tinyglobby default-expansion edge case and confirms the CLI preserves the existing failure contract and JSON error shape.

Also applies to: 527-557


📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Replaced the project's file-globbing library with a lighter-weight alternative.
    • Updated CLI and tooling file discovery to preserve existing pattern-matching and directory behavior.
    • Added/adjusted tests to confirm unchanged end-to-end behavior when using include/exclude patterns.

Walkthrough

Replaces fast-glob with tinyglobby across manifests and source files, updates imports to glob as fg, adds expandDirectories: false to relevant glob calls to preserve directory-pattern semantics, and adds a changeset and a test for bare-directory include behavior.

Changes

Replace fast-glob with tinyglobby

Layer / File(s) Summary
Dependency Declarations
.changeset/replace-fast-glob-with-tinyglobby.md, evals/package.json, packages/leadtype/package.json
Changeset added; fast-glob removed and tinyglobby@0.2.16 added to dev/main dependencies.
Evaluation Tools Globbing Import
evals/lib/tools.ts
Import switched to tinyglobby (glob as fg) and expandDirectories: false added to the glob tool options.
Leadtype Source Globbing Imports & Options
packages/leadtype/src/cli.test.ts, packages/leadtype/src/cli/generate.ts, packages/leadtype/src/convert/convert.ts, packages/leadtype/src/lint/runner.ts
Source and test imports changed to tinyglobby (glob as fg); relevant glob calls now pass expandDirectories: false. A test asserting --include build (bare directory) returns no matches was added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰
I hopped through code with gentle feet,
swapped big-glob for something neat.
Tiny and tidy, footprint light,
patterns same — the tests sleep tight.
A crunchy carrot, dependency sweet.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Replace fast-glob with tinyglobby' directly and clearly summarizes the main change across all modified files.
Description check ✅ Passed The description comprehensively documents the drop-in swap, call-site preservation strategy, performance benchmarks, dependency footprint reduction, and test results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kaylee/replace-fast-glob-with-tinyglobby

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf350d6b34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

import fg from "fast-glob";
import matter from "gray-matter";
import { createJiti } from "jiti";
import { glob as fg } from "tinyglobby";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Set expandDirectories false for fast-glob parity

When users pass a static directory pattern through --include (for example --include guides), this import changes the behavior of the later fg(patterns, { onlyFiles: true, ... }) call: tinyglobby enables expandDirectories by default and its migration docs say to disable it when migrating from fast-glob, so the pattern now expands to files under that directory instead of matching no files as fast-glob did with onlyFiles. That makes filtered bundle/site generation include an entire directory for inputs that previously failed with “No MDX files matched,” so add expandDirectories: false at the migrated call sites that need fast-glob semantics.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
evals/lib/tools.ts (1)

220-225: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update stale dependency reference in tool help text

Line 224 references "fast-glob pattern" but this file now uses tinyglobby. Update the description to reflect the current implementation.

Suggested change
-            "fast-glob pattern, e.g. '**/*.md', 'src/**/*.ts', 'node_modules/leadtype/docs/**/*.md'"
+            "Glob pattern, e.g. '**/*.md', 'src/**/*.ts', 'node_modules/leadtype/docs/**/*.md'"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@evals/lib/tools.ts` around lines 220 - 225, The help text for the pattern
field is outdated: update the description in the inputSchema's pattern
z.string().describe(...) to reference the current matcher (tinyglobby) instead
of "fast-glob"; e.g. change "fast-glob pattern" to "glob pattern supported by
tinyglobby" and keep the example patterns as-is so the description accurately
reflects the implementation used by the pattern validator.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@evals/lib/tools.ts`:
- Around line 220-225: The help text for the pattern field is outdated: update
the description in the inputSchema's pattern z.string().describe(...) to
reference the current matcher (tinyglobby) instead of "fast-glob"; e.g. change
"fast-glob pattern" to "glob pattern supported by tinyglobby" and keep the
example patterns as-is so the description accurately reflects the implementation
used by the pattern validator.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e6390cd9-ae26-469d-ad46-6157b534ee15

📥 Commits

Reviewing files that changed from the base of the PR and between 4c7ab4c and cf350d6.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .changeset/replace-fast-glob-with-tinyglobby.md
  • evals/lib/tools.ts
  • evals/package.json
  • packages/leadtype/package.json
  • packages/leadtype/src/cli.test.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/convert/convert.ts
  • packages/leadtype/src/lint/runner.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use const assertions (as const) for immutable values and literal types
Leverage TypeScript's type narrowing instead of type assertions

Files:

  • evals/lib/tools.ts
  • packages/leadtype/src/lint/runner.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/cli.test.ts
  • packages/leadtype/src/convert/convert.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use meaningful variable names instead of magic numbers - extract constants with descriptive names
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, never var
Always await promises in async functions - don't forget to use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors
Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully - don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Don't use eval() or assign directly to document.cookie
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports
Use descriptive names for functions, variables, and types for meaningful naming
Add comments for complex logic, but prefer self-documenting code

Files:

  • evals/lib/tools.ts
  • packages/leadtype/src/lint/runner.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/cli.test.ts
  • packages/leadtype/src/convert/convert.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.{js,ts,jsx,tsx}: Write assertions inside it() or test() blocks
Avoid done callbacks in async tests - use async/await instead
Don't use .only or .skip in committed code
Keep test suites reasonably flat - avoid excessive describe nesting

Files:

  • packages/leadtype/src/cli.test.ts
🪛 markdownlint-cli2 (0.22.1)
.changeset/replace-fast-glob-with-tinyglobby.md

[warning] 5-5: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

tinyglobby expands bare directory names (`build` → `build/**`) by
default; fast-glob did not. Without this option, `leadtype generate
--include build` silently slurped every MDX file under `docs/build/`
instead of reporting "No MDX files matched" the way fast-glob did
with `onlyFiles: true`.

Disable expandDirectories at the three call sites that take
user-/agent-supplied patterns:

- packages/leadtype/src/cli/generate.ts (CLI --include/--exclude)
- packages/leadtype/src/lint/runner.ts (LintOptions ignore)
- evals/lib/tools.ts (agent-facing glob tool)

Hardcoded patterns elsewhere (**/*.mdx, **/*, leadtype-generate-*)
can't trigger directory expansion, so they're left alone.

Regression test covers the exact `--include <bare-dir>` path.
@KayleeWilliams
Copy link
Copy Markdown
Collaborator Author

Follow-up commit 70603c7: pin expandDirectories: false at the three call sites that take user- or agent-supplied patterns.

Why: tinyglobby expands bare directory names (buildbuild/**) by default; fast-glob does not. Without the flag, leadtype generate --include build silently slurped every MDX under docs/build/ instead of reporting "No MDX files matched" the way it did with fast-glob + onlyFiles: true. Same shape applies anywhere a user/agent can pass a pattern.

Where:

  • packages/leadtype/src/cli/generate.ts (CLI --include/--exclude)
  • packages/leadtype/src/lint/runner.ts (LintOptions ignore can be user-supplied)
  • evals/lib/tools.ts (agent-facing glob tool)

Hardcoded patterns elsewhere (**/*.mdx, **/*, leadtype-generate-*) can't trigger directory expansion, so they're left alone.

Regression test: added treats a bare directory in --include as matching no MDX files in cli.test.ts. Verified it fails on the prior commit (code=0 returned) and passes after the fix (code=1 with "No MDX files matched").

164 tests pass (147 leadtype + 17 evals).

@KayleeWilliams KayleeWilliams merged commit 3e03d9d into main May 11, 2026
3 checks passed
@KayleeWilliams KayleeWilliams deleted the kaylee/replace-fast-glob-with-tinyglobby branch May 11, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant