From 609a342986b2d3b05ef59dc23523239938264008 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 24 Sep 2021 16:55:59 -0400 Subject: [PATCH] fix(plugin-vue): handle rewrite default edge case with TS ref https://github.com/vuejs/vue-next/issues/4673 --- packages/plugin-vue/src/main.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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) {