if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
const match = filename.match(/([^/\\]+)\.\w+$/)
if (match) {
- runtimeOptions += `\n name: '${match[1]}',`
+ runtimeOptions += `\n __name: '${match[1]}',`
}
}
if (hasInlinedSsrRenderFn) {
* This one should be exposed so that devtools can make use of it
*/
__file?: string
+ /**
+ * name inferred from filename
+ */
+ __name?: string
}
export interface FunctionalComponent<P = {}, E extends EmitsOptions = {}>
str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '')
export function getComponentName(
- Component: ConcreteComponent
-): string | undefined {
+ Component: ConcreteComponent,
+ includeInferred = true
+): string | false | undefined {
return isFunction(Component)
? Component.displayName || Component.name
- : Component.name
+ : Component.name || (includeInferred && Component.__name)
}
/* istanbul ignore next */
// explicit self name has highest priority
if (type === COMPONENTS) {
- const selfName = getComponentName(Component)
+ const selfName = getComponentName(
+ Component,
+ false /* do not include inferred name to avoid breaking existing code */
+ )
if (
selfName &&
(selfName === name ||