diff --git a/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts b/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts
index fe52b12d4e5..81996209a92 100644
--- a/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts
+++ b/packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts
@@ -250,3 +250,18 @@ test('check when has explicit parse options', () => {
)
expect(content).toMatch('return { get x() { return x } }')
})
+
+test('shorthand binding w/ kebab-case', () => {
+ const { content } = compile(
+ `
+
+
+
+
+
+ `,
+ )
+ expect(content).toMatch('return { get fooBar() { return fooBar }')
+})
diff --git a/packages/compiler-sfc/src/script/importUsageCheck.ts b/packages/compiler-sfc/src/script/importUsageCheck.ts
index 6b9fbc634cc..c52ae391ee0 100644
--- a/packages/compiler-sfc/src/script/importUsageCheck.ts
+++ b/packages/compiler-sfc/src/script/importUsageCheck.ts
@@ -8,7 +8,12 @@ import {
walkIdentifiers,
} from '@vue/compiler-dom'
import { createCache } from '../cache'
-import { camelize, capitalize, isBuiltInDirective } from '@vue/shared'
+import {
+ camelize,
+ capitalize,
+ hyphenate,
+ isBuiltInDirective,
+} from '@vue/shared'
/**
* Check if an import is used in the SFC's template. This is used to determine
@@ -16,7 +21,8 @@ import { camelize, capitalize, isBuiltInDirective } from '@vue/shared'
* when not using inline mode.
*/
export function isImportUsed(local: string, sfc: SFCDescriptor): boolean {
- return resolveTemplateUsedIdentifiers(sfc).has(local)
+ const set = resolveTemplateUsedIdentifiers(sfc)
+ return set.has(local) || set.has(hyphenate(local))
}
const templateUsageCheckCache = createCache>()