Replace fast-glob with tinyglobby#29
Conversation
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.
There was a problem hiding this comment.
💡 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"; |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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 winUpdate 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
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
.changeset/replace-fast-glob-with-tinyglobby.mdevals/lib/tools.tsevals/package.jsonpackages/leadtype/package.jsonpackages/leadtype/src/cli.test.tspackages/leadtype/src/cli/generate.tspackages/leadtype/src/convert/convert.tspackages/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
Preferunknownoveranywhen 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.tspackages/leadtype/src/lint/runner.tspackages/leadtype/src/cli/generate.tspackages/leadtype/src/cli.test.tspackages/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
Preferfor...ofloops over.forEach()and indexedforloops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Useconstby default,letonly when reassignment is needed, nevervar
Alwaysawaitpromises in async functions - don't forget to use the return value
Useasync/awaitsyntax 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
Removeconsole.log,debugger, andalertstatements from production code
ThrowErrorobjects with descriptive messages, not strings or other values
Usetry-catchblocks 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 useeval()or assign directly todocument.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.tspackages/leadtype/src/lint/runner.tspackages/leadtype/src/cli/generate.tspackages/leadtype/src/cli.test.tspackages/leadtype/src/convert/convert.ts
**/*.{test,spec}.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{test,spec}.{js,ts,jsx,tsx}: Write assertions insideit()ortest()blocks
Avoid done callbacks in async tests - use async/await instead
Don't use.onlyor.skipin committed code
Keep test suites reasonably flat - avoid excessivedescribenesting
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.
|
Follow-up commit 70603c7: pin Why: tinyglobby expands bare directory names ( Where:
Hardcoded patterns elsewhere ( Regression test: added 164 tests pass (147 leadtype + 17 evals). |
Summary
Drop-in swap of
fast-glob→tinyglobbyper the e18e replacement guide. Affects 5 call sites inpackages/leadtypeandevals/.The shape of every call site is preserved by aliasing the named export at the import:
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-filenode_modules/corpus (300 iterations after warm-up):convert.ts—**/*.mdxindocs/generate.tsinferGroups —**/*.mdxgenerate.tshasFilters —**/*.mdx+ excludelint/runner.ts—**/*.ts(x)+ ignore overpackages/evals/tools.tsgrep —**/*over node_modules (~600 files)evals/tools.tsglob —**/*.d.tsover node_modulesRuntime is a wash — every call site touches small directories so neither library dominates. The real win is dependency footprint:
fast-globclosuretinyglobbyclosure13 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).picomatchis shared between both.Test plan
bun x ultracite check— cleanbun run check-types— passesbun run testinpackages/leadtype— 146/146 passbun run testinevals— 17/17 pass🤖 Generated with Claude Code