feat: allow sort files
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
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.
@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
Converted to draft until tinyglobby is released with the feature
I'm going to remove tinyglobby here and use picomatch + fsdir directly