From dece6102aa84c115a3d6481c6e0f27e5b4be3ef1 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 20 Apr 2020 16:17:29 -0400 Subject: [PATCH] feat(warn): infer anonymous component named based on resolve name --- .../runtime-core/src/helpers/resolveAssets.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/helpers/resolveAssets.ts b/packages/runtime-core/src/helpers/resolveAssets.ts index fe38ef88..40440f6c 100644 --- a/packages/runtime-core/src/helpers/resolveAssets.ts +++ b/packages/runtime-core/src/helpers/resolveAssets.ts @@ -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, @@ -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__) {