Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork378
feat: allow sort files#885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
|
userquin commentedSep 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We need to change the local tinyglobby tgz copy with pkg-pr-new from this PR (in a few minutes I'll send an update ✔️ done):SuperchupuDev/tinyglobby#168 and once released 🤞 just update the dependency. |
@antfu any chance to add pkg-pr-new in the repo? I can send a PR to add it, I only need pkg-pr-new installed, oh wait, this is unplugin, it should be ready iirc |
src/types.ts Outdated
| * | ||
| * For example, you can sort the files in descending order providing the following sort option: | ||
| * ```ts | ||
| * sort(_root, files): Generator<string, undefined, void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
missing * before sort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
.npmrc Outdated
| @@ -0,0 +1 @@ | |||
| shell-emulator=true No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Let's put it in the pnpm-workspace.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done
| * | ||
| * `unplugin-vue-components` using `tinyglobby` to scan files, which is non-deterministic. | ||
| */ | ||
| sortByGlob?:true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Add some warning here about performance when enabling this option, will beO(F * M) whereF is the number of files andM the "picomatch" search patterns logic, check thesortFilesByGlobPrecedence function.
| *@param root The root folder of the project. | ||
| *@param files The scanned files (it is a new array). | ||
| */ | ||
| sort?:(root:string,files:string[])=>Generator<string,undefined,void> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Maybe we can add built-in asc/desc sort support, changing sort to:
sort?:'asc'|'desc'|((root:string,files:string[])=>Generator<string,undefined,void>)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If asc/desc here and sortByGlob enabled just show a warning disabling sortByGlob
Converted to draft until tinyglobby is released with the feature |

Uh oh!
There was an error while loading.Please reload this page.
DO NOT MERGE YET: we need to await tinyglobby release 🤞 (SuperchupuDev/tinyglobby#168)
I need to check when
sortFilesByGlobPrecedenceshould be called, I'm not sure how dirs and globs are "connected" here, this comment confuse mehttps://github.com/unplugin/unplugin-vue-components/blob/main/src/types.ts#L94. I guess we also need to check if globs there from raw options before callingsortFilesByGlobPrecedenceherehttps://github.com/unplugin/unplugin-vue-components/pull/885/files#diff-c02b4d62dc54667a8a1243f8ddc5ae0a604cc5d7218d94fd69bfda1c8514ce1fR215-R222, this should be:where
hasGlobsshould be initialized in the constructor usingthis.hasGlobs = rawOptions.globs?.lenght > 0SuperchupuDev/tinyglobby#166
closes#831