unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

feat: allow sort files

Open userquin opened this issue 2 months ago • 5 comments

DO NOT MERGE YET: we need to await tinyglobby release 🤞 (https://github.com/SuperchupuDev/tinyglobby/pull/168)

I need to check when sortFilesByGlobPrecedence should be called, I'm not sure how dirs and globs are "connected" here, this comment confuse me https://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 calling sortFilesByGlobPrecedence here https://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
    }
  }

where hasGlobs should be initialized in the constructor using this.hasGlobs = rawOptions.globs?.lenght > 0

https://github.com/SuperchupuDev/tinyglobby/issues/166

closes #831

userquin avatar Sep 25 '25 19:09 userquin

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

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): https://github.com/SuperchupuDev/tinyglobby/pull/168

and once released 🤞 just update the dependency.

userquin avatar Sep 26 '25 19:09 userquin

@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

userquin avatar Sep 26 '25 20:09 userquin

Converted to draft until tinyglobby is released with the feature

antfu avatar Oct 19 '25 22:10 antfu

I'm going to remove tinyglobby here and use picomatch + fsdir directly

userquin avatar Nov 11 '25 17:11 userquin