Skip to content

Commit

Permalink
feat(warn): infer anonymous component named based on resolve name
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 20, 2020
1 parent 0278992 commit dece610
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/runtime-core/src/helpers/resolveAssets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { currentRenderingInstance } from '../componentRenderUtils'
import { currentInstance, Component, FunctionalComponent } from '../component'
import {
currentInstance,
Component,
FunctionalComponent,
ComponentOptions
} from '../component'
import { Directive } from '../directives'
import {
camelize,
Expand Down Expand Up @@ -69,8 +74,15 @@ function resolveAsset(
res = self
}
}
if (__DEV__ && warnMissing && !res) {
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
if (__DEV__) {
if (res) {
// in dev, infer anonymous component's name based on registered name
if (type === COMPONENTS && !(res as Component).name) {
;(res as ComponentOptions).name = name
}
} else if (warnMissing) {
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
}
}
return res
} else if (__DEV__) {
Expand Down

0 comments on commit dece610

Please sign in to comment.