]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(warn): infer anonymous component named based on resolve name
authorEvan You <yyx990803@gmail.com>
Mon, 20 Apr 2020 20:17:29 +0000 (16:17 -0400)
committerEvan You <yyx990803@gmail.com>
Mon, 20 Apr 2020 20:17:29 +0000 (16:17 -0400)
packages/runtime-core/src/helpers/resolveAssets.ts

index fe38ef887a3451f5b0625f30a1befe04fa556bb5..40440f6cf6930b655cadb52bb99bfee282096d17 100644 (file)
@@ -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__) {