fix(nuxt): allow overriding components + only warn if clash (#23156)

This commit is contained in:
Daniel Roe 2023-09-12 21:47:42 +01:00 committed by GitHub
parent 0612786544
commit 3e1ad3e20b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,7 +140,12 @@ export async function scanComponents (dirs: ComponentsDir[], srcDir: string): Pr
const existingPriority = existingComponent.priority ?? 0
const newPriority = component.priority ?? 0
if (newPriority >= existingPriority) {
// Replace component if priority is higher
if (newPriority > existingPriority) {
components.splice(components.indexOf(existingComponent), 1, component)
}
// Warn if a user-defined (or prioritised) component conflicts with a previously scanned component
if (newPriority > 0 && newPriority === existingPriority) {
warnAboutDuplicateComponent(componentName, filePath, existingComponent.filePath)
}