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 our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(kit,nuxt): add component priority
to allow overriding
#19252
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
I have initially removed Regarding built-ins, I agree with your comment in #19221 (comment). Same for built-in composables, fetch, etc, With auto imports and implicit sources, allowing a built-in to be overridden by the user, can cause unwanted behavior by any module, theme layer, and code that was depending on Nuxt behavior and now is changed! (a layer can break another layer too). So i believe we might give Nuxt Built-ins priority too and document only as advanced escape hatch to override them if really needed. Default priority: Built-ins > User Components > Layer 1 > Layer 2 > Module Aded [can be overridden with |
What is the main advantage of overwriting built-ins components? It can also create confusion for team members working on a Nuxt project with overwritten built-in components. |
Co-authored-by: Damian GΕowala <48835293+DamianGlowala@users.noreply.github.com>
The Nuxt component built-ins are:
Of those, I think that it would be safe (and good DX) if users could provide their own implementations for For the other built-in components, their priority when registering them that ensures that it would require extra effort to override them, but still allows an escape hatch for advanced use cases. wdyt?
That is the implementation here - user components are given a default priority of 1, which means they will override module components. |
Nice summary and LGTM. Btw this also opens a design in consistency in Nuxt where some built-ins are exceptions to be globally overriding. they both support custom slots for being customized. For the component libraries needing to extend, they could support opt-in |
π Linked issue
resolves #19221
β Type of change
π Description
In line with the
priority
option support by auto-imported composables/utils, this PR adds apriority
to components to allow them to override other components. By default, user components have a higher priority than components injected by modules without an explicit priority, but not higher than any Nuxt built-in components.π Checklist