Skip to content

Commit dece610

Browse files
committed
feat(warn): infer anonymous component named based on resolve name
1 parent 0278992 commit dece610

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/runtime-core/src/helpers/resolveAssets.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { currentRenderingInstance } from '../componentRenderUtils'
2-
import { currentInstance, Component, FunctionalComponent } from '../component'
2+
import {
3+
currentInstance,
4+
Component,
5+
FunctionalComponent,
6+
ComponentOptions
7+
} from '../component'
38
import { Directive } from '../directives'
49
import {
510
camelize,
@@ -69,8 +74,15 @@ function resolveAsset(
6974
res = self
7075
}
7176
}
72-
if (__DEV__ && warnMissing && !res) {
73-
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
77+
if (__DEV__) {
78+
if (res) {
79+
// in dev, infer anonymous component's name based on registered name
80+
if (type === COMPONENTS && !(res as Component).name) {
81+
;(res as ComponentOptions).name = name
82+
}
83+
} else if (warnMissing) {
84+
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
85+
}
7486
}
7587
return res
7688
} else if (__DEV__) {

0 commit comments

Comments
 (0)