diff --git a/packages/compiler-core/src/transform.ts b/packages/compiler-core/src/transform.ts index 4650c368557..fc56ddf5649 100644 --- a/packages/compiler-core/src/transform.ts +++ b/packages/compiler-core/src/transform.ts @@ -22,7 +22,8 @@ import { isArray, NOOP, PatchFlags, - PatchFlagNames + PatchFlagNames, + EMPTY_OBJ } from '@vue/shared' import { defaultOnError } from './errors' import { @@ -122,7 +123,7 @@ export function createTransformContext( scopeId = null, ssr = false, ssrCssVars = ``, - bindingMetadata = {}, + bindingMetadata = EMPTY_OBJ, onError = defaultOnError }: TransformOptions ): TransformContext { diff --git a/packages/compiler-core/src/transforms/transformElement.ts b/packages/compiler-core/src/transforms/transformElement.ts index 8a6d39a376a..53b591fc03b 100644 --- a/packages/compiler-core/src/transforms/transformElement.ts +++ b/packages/compiler-core/src/transforms/transformElement.ts @@ -26,7 +26,10 @@ import { isSymbol, isOn, isObject, - isReservedProp + isReservedProp, + capitalize, + camelize, + EMPTY_OBJ } from '@vue/shared' import { createCompilerError, ErrorCodes } from '../errors' import { @@ -246,8 +249,15 @@ export function resolveComponentType( } // 3. user component (from setup bindings) - if (context.bindingMetadata[tag] === 'setup') { - return `$setup[${JSON.stringify(tag)}]` + let tagFromSetup = tag + const bindings = context.bindingMetadata + if ( + bindings !== EMPTY_OBJ && + (bindings[tagFromSetup] === 'setup' || + bindings[(tagFromSetup = camelize(tag))] === 'setup' || + bindings[(tagFromSetup = capitalize(camelize(tag)))] === 'setup') + ) { + return `$setup[${JSON.stringify(tagFromSetup)}]` } // 4. user component (resolve) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 841c60ecfef..45cdea72256 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -41,7 +41,7 @@ const hasWarned: Record = {} function warnOnce(msg: string) { if (!hasWarned[msg]) { hasWarned[msg] = true - console.log(`\n\x1b[33m[@vue/compiler-sfc] %s\x1b[0m\n`, msg) + console.log(`\x1b[33m[@vue/compiler-sfc] %s\x1b[0m\n`, msg) } } @@ -59,7 +59,7 @@ export function compileScript( if (__DEV__ && !__TEST__ && scriptSetup) { warnOnce( `