Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
userquin wants to merge6 commits intomain
base:main
Choose a base branch
Loading
fromuserquin/feat-allow-sort-files

Conversation

@userquin
Copy link
Member

@userquinuserquin commentedSep 25, 2025
edited
Loading

DO NOT MERGE YET: we need to await tinyglobby release 🤞 (SuperchupuDev/tinyglobby#168)

I need to check whensortFilesByGlobPrecedence should 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 callingsortFilesByGlobPrecedence herehttps://github.com/unplugin/unplugin-vue-components/pull/885/files#diff-c02b4d62dc54667a8a1243f8ddc5ae0a604cc5d7218d94fd69bfda1c8514ce1fR215-R222, this should be:

private*preparePaths():Generator<string,undefined,void>{if(this.options.sortByGlob&&this.hasGlobs){yield*sortFilesByGlobPrecedence(this,this._componentPaths)}else{yield*this._componentPaths}}

wherehasGlobs should be initialized in the constructor usingthis.hasGlobs = rawOptions.globs?.lenght > 0

SuperchupuDev/tinyglobby#166

closes#831

ilyaliao reacted with thumbs up emoji
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz CodeflowRun & review this pull request inStackBlitz Codeflow.

@userquinuserquin marked this pull request as draftSeptember 25, 2025 19:25
@userquinuserquin marked this pull request as ready for reviewSeptember 26, 2025 19:49
@userquin
Copy link
MemberAuthor

userquin commentedSep 26, 2025
edited
Loading

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.

@userquin
Copy link
MemberAuthor

@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> {
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

missing * before sort

Copy link
MemberAuthor

@userquinuserquinSep 26, 2025
edited
Loading

Choose a reason for hiding this comment

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

arggg the linter removing it, I need to check@antfu/eslint-config to disable the rule.

Looks like this works, luckely the object-shorthand rule not being applied ;) (check the screenshot below):

sort:function*(_root,files):Generator<string,undefined,void>{yield*files.sort((a,b)=>b.localeCompare(a))},
image

.npmrc Outdated
@@ -0,0 +1 @@
shell-emulator=true No newline at end of file
Copy link
Member

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

userquin reacted with thumbs up emoji
Copy link
MemberAuthor

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
Copy link
MemberAuthor

@userquinuserquinSep 27, 2025
edited
Loading

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>
Copy link
MemberAuthor

@userquinuserquinSep 27, 2025
edited
Loading

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>)

Copy link
MemberAuthor

@userquinuserquinSep 27, 2025
edited
Loading

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

@antfuantfu marked this pull request as draftOctober 19, 2025 22:55
@antfu
Copy link
Member

Converted to draft until tinyglobby is released with the feature

userquin reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@antfuantfuantfu left review comments

@ilyaliaoilyaliaoAwaiting requested review from ilyaliao

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

When usingtinyglobby get wrong components files order

3 participants

@userquin@antfu

[8]ページ先頭

©2009-2025 Movatter.jp