File tree 2 files changed +10
-12
lines changed
packages/runtime-core/src
2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export interface SFCInternalOptions {
52
52
__cssModules ?: Data
53
53
__hmrId ?: string
54
54
__hmrUpdated ?: boolean
55
+ __file ?: string
55
56
}
56
57
57
58
export interface FunctionalComponent <
@@ -540,16 +541,16 @@ const classify = (str: string): string =>
540
541
541
542
export function formatComponentName (
542
543
Component : Component ,
543
- file ?: string
544
+ isRoot = false
544
545
) : string {
545
546
let name = isFunction ( Component )
546
547
? Component . displayName || Component . name
547
548
: Component . name
548
- if ( ! name && file ) {
549
- const match = file . match ( / ( [ ^ / \\ ] + ) \. v u e $ / )
549
+ if ( ! name && Component . __file ) {
550
+ const match = Component . __file . match ( / ( [ ^ / \\ ] + ) \. v u e $ / )
550
551
if ( match ) {
551
552
name = match [ 1 ]
552
553
}
553
554
}
554
- return name ? classify ( name ) : ' Anonymous'
555
+ return name ? classify ( name ) : isRoot ? `App` : ` Anonymous`
555
556
}
Original file line number Diff line number Diff line change @@ -48,10 +48,7 @@ export function warn(msg: string, ...args: any[]) {
48
48
msg + args . join ( '' ) ,
49
49
instance && instance . proxy ,
50
50
trace
51
- . map (
52
- ( { vnode } ) =>
53
- `at <${ formatComponentName ( vnode . type as Component ) } >`
54
- )
51
+ . map ( ( { vnode } ) => `at <${ formatComponentName ( vnode . type ) } >` )
55
52
. join ( '\n' ) ,
56
53
trace
57
54
]
@@ -111,12 +108,12 @@ function formatTrace(trace: ComponentTraceStack): any[] {
111
108
function formatTraceEntry ( { vnode, recurseCount } : TraceEntry ) : any [ ] {
112
109
const postfix =
113
110
recurseCount > 0 ? `... (${ recurseCount } recursive calls)` : ``
114
- const open = ` at <${ formatComponentName ( vnode ) } `
111
+ const isRoot = vnode . component ! . parent == null
112
+ const open = ` at <${ formatComponentName ( vnode . type , isRoot ) } `
115
113
const close = `>` + postfix
116
- const rootLabel = vnode . component ! . parent == null ? `(Root)` : ``
117
114
return vnode . props
118
- ? [ open , ...formatProps ( vnode . props ) , close , rootLabel ]
119
- : [ open + close , rootLabel ]
115
+ ? [ open , ...formatProps ( vnode . props ) , close ]
116
+ : [ open + close ]
120
117
}
121
118
122
119
function formatProps ( props : Data ) : any [ ] {
You can’t perform that action at this time.
0 commit comments