Skip to content

Too many directories are scanned with multi-patterns #77

@fabianwohlfart

Description

@fabianwohlfart

If I have two patterns like this

const files = await glob(['../app/**/*.vue', '../utilities/**/*.vue'])

and a folder structure like this

- app
- should-not-matter
- utilities

not only the app and utilities folder are searched, but also the should-not-matter folder.
This leads to huge performance breakdowns, if not only one, but many folders are »in between«.

I came to this behavior through a weird warning in Nuxt, where suddenly my build process increased from 500ms to 25seconds.
nuxt/nuxt#30137

I tracked it down to a scanDirectory function in unimport, that took longer than expected
unjs/unimport#401

I came to the conclusion that they recently switched from glob to tinyglobby
Yet glob only takes a few milliseconds, but tinyglobby takes seconds to scan everything.

Here is a reproduction.
https://github.com/fabianwohlfart/test__nuxt-layers-slowdown

You can simply go to the app folder and run the tinyglobby.mjs, you will see that it searches the folder should-not-matter, which it shouldn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions