Conversation
|
|
|
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.
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))
},
.npmrc
Outdated
| @@ -0,0 +1 @@ | |||
| shell-emulator=true No newline at end of file | |||
There was a problem hiding this comment.
Let's put it in the pnpm-workspace.yaml
| * | ||
| * `unplugin-vue-components` using `tinyglobby` to scan files, which is non-deterministic. | ||
| */ | ||
| sortByGlob?: true |
There was a problem hiding this comment.
Add some warning here about performance when enabling this option, will be O(F * M) where F is the number of files and M the "picomatch" search patterns logic, check the sortFilesByGlobPrecedence 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.
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.
If asc/desc here and sortByGlob enabled just show a warning disabling sortByGlob
|
Converted to draft until tinyglobby is released with the feature |
|
I'm going to remove tinyglobby here and use picomatch + fsdir directly |
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 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 callingsortFilesByGlobPrecedencehere https://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