mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(kit): don't mutate existing component entry when overriding (#25786)
This commit is contained in:
parent
936ad91b0a
commit
363bb57b63
@ -52,8 +52,9 @@ export async function addComponent (opts: AddComponentOptions) {
|
||||
}
|
||||
|
||||
nuxt.hook('components:extend', (components: Component[]) => {
|
||||
const existingComponent = components.find(c => (c.pascalName === component.pascalName || c.kebabName === component.kebabName) && c.mode === component.mode)
|
||||
if (existingComponent) {
|
||||
const existingComponentIndex = components.findIndex(c => (c.pascalName === component.pascalName || c.kebabName === component.kebabName) && c.mode === component.mode)
|
||||
if (existingComponentIndex !== -1) {
|
||||
const existingComponent = components[existingComponentIndex]
|
||||
const existingPriority = existingComponent.priority ?? 0
|
||||
const newPriority = component.priority ?? 0
|
||||
|
||||
@ -65,7 +66,7 @@ export async function addComponent (opts: AddComponentOptions) {
|
||||
const name = existingComponent.pascalName || existingComponent.kebabName
|
||||
logger.warn(`Overriding ${name} component. You can specify a \`priority\` option when calling \`addComponent\` to avoid this warning.`)
|
||||
}
|
||||
Object.assign(existingComponent, component)
|
||||
components.splice(existingComponentIndex, 1, component)
|
||||
} else {
|
||||
components.push(component)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user