diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 8e4a2af6bdd65b..9ddb73ea61c078 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -272,7 +272,15 @@ async function genScriptCode( // If the script is js/ts and has no external src, it can be directly placed // in the main module. if ((!script.lang || script.lang === 'ts') && !script.src) { - scriptCode = compiler.rewriteDefault(script.content, '_sfc_main') + scriptCode = compiler.rewriteDefault( + script.content, + '_sfc_main', + script.lang === 'ts' + ? ['typescript'] + : script.lang === 'tsx' + ? ['typescript', 'jsx'] + : undefined + ) map = script.map } else { if (script.src) {