Skip to content

Commit 1618c0a

Browse files
committed
chore: updated warning info
1 parent f0dcf9e commit 1618c0a

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

packages/compiler-core/__tests__/transforms/transformElement.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ describe('compiler: element transform', () => {
9898
expect(node.tag).toBe(`$setup["Example"]`)
9999
})
100100

101+
test('resolve component from setup bindings & component', () => {
102+
const { root, node } = parseWithElementTransform(`<Example/>`, {
103+
bindingMetadata: {
104+
Example: BindingTypes.SETUP_CONST
105+
}
106+
})
107+
expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
108+
expect(node.tag).toBe(`_resolveSetupReturned("Example", $setup)`)
109+
})
110+
101111
test('resolve component from setup bindings (inline)', () => {
102112
const { root, node } = parseWithElementTransform(`<Example/>`, {
103113
inline: true,

packages/runtime-core/src/helpers/resolveAssets.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,16 @@ function resolveAsset(
116116
warnMissing &&
117117
((!res && !isLateTag(name)) || (res && isLateTag(name)))
118118
) {
119-
const extra =
120-
type === COMPONENTS
121-
? `\nIf this is a native custom element, make sure to exclude it from ` +
119+
let extra = ''
120+
if (type === COMPONENTS) {
121+
if (isLateTag(name)) {
122+
extra = `\nplease do not use built-in tag names as component names.`
123+
} else {
124+
extra =
125+
`\nIf this is a native custom element, make sure to exclude it from ` +
122126
`component resolution via compilerOptions.isCustomElement.`
123-
: ``
127+
}
128+
}
124129
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`)
125130
}
126131

@@ -145,14 +150,12 @@ function resolve(registry: Record<string, any> | undefined, name: string) {
145150
/**
146151
* @private
147152
*/
148-
export function resolveSetupReturned(name:string, setupReturn: any) {
149-
if(!setupReturn) return name
153+
export function resolveSetupReturned(name: string, setupReturn: any) {
154+
if (!setupReturn) return name
150155
const returnValue = setupReturn[name]
151-
if(returnValue && returnValue.__file && isLateTag(name as string)){
152-
const extra =
153-
`\nIf this is a native custom element, make sure to exclude it from ` +
154-
`component resolution via compilerOptions.isCustomElement.`
155-
warn(`Failed to resolve component: ${name}${extra}`)
156+
if (returnValue && returnValue.__file && isLateTag(name as string)) {
157+
const extra = `\nplease do not use built-in tag names as component names.`
158+
warn(`Failed to resolve component: ${name},${extra}`)
156159
}
157160
return returnValue
158161
}

0 commit comments

Comments
 (0)