Skip to content

💡 Fast-path literal (non-glob) patterns instead of passing them all to tinyglobby #1876

Description

@jasonsliu

Suggest an idea for Knip

This is a performance improvement suggestion which is needed after knip switched from fast-glob to tinyglobby:

When a package.json exports/imports map is expanded into entry paths, those targets are handed straight to tinyglobby.

In a large monorepo with generated-types workspaces, one map can expand to many (tens of thousands in our repo) literal patterns. tinyglobby tests each walked entry against every compiled pattern even though a literal can only match one exact path.

Suggested fix: In glob(), we can split patterns into literals vs real globs. Literals can be resolved directly with isFile() (the fast path), and only real globs can be passed is tinyGlob.

In our large monorepo, patching this decreased our knip runtime from 10+ min to ~1.5 minutes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions