Repository navigation
Conversation
Sort component paths by the index of the first glob they match before building the name map, so the configured order decides which component wins under `allowOverrides`, both for the initial scan and for files added later through the watcher. Closes unplugin#831
|
|
5 tasks done
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since the switch from fast-glob to tinyglobby, the component that wins under
allowOverridesdepends on the order tinyglobby walks the filesystem. That order is not the order ofdirs/globs(#831). Files added later through the watcher (HMR) also land at the end of theSet, so a lower-priority file that is re-added can override a higher-priority one.This PR leaves the glob layer alone.
Context.updateComponentNameMap()now sorts component paths by the index of the first configured glob they match and useslocaleCompareto break ties:dirs/globsoverride earlier ones underallowOverrides: true. This matches the fast-glob behavior from v28.allowOverrides, the first dir wins and later duplicates get the existing warning.addComponentsdirectly) sort last.picomatchis already a dependency.The change is 15 lines in
src/core/context.ts. It adds no option and no dependency change.Relation to #905
#905 by @userquin adds a
sortoption on top of tinyglobby's proposed sort support (SuperchupuDev/tinyglobby#189). This PR is meant as a dependency-free complement to it. It fixes the default order, and #905'ssortoption could still be layered on top for users who want a different order inside each glob.Linked Issues
Closes #831
Additional context
Tests (
test/search.test.ts, fixtures intest/fixtures/override/{base,theme,user}):dirs: ['base', 'theme', 'user']:user/Button.vuewins, andbase/Badge.vueis still resolved.globsin reverse path order (user,theme,base):base/Button.vuewins, which shows that the globs order decides and the path order does not.removeComponents+addComponentson the lower-prioritytheme/Button.vue(simulating HMR):user/Button.vuestill wins.allowOverrides, the first dir wins.Without the
context.tschange, 3 of the 4 new tests fail.vitest,eslintandtsgoall pass, and no existing snapshot changed.Context: Valaxy layers components from core → theme → addons → user dirs and relies on later dirs winning. It currently vendors a patched copy of this plugin for that reason alone. This PR upstreams that patch.