fix(sfc): only enable jsx parser plugin when explicitly using tsx

fix #4106
This commit is contained in:
Evan You 2021-07-15 13:12:06 -04:00
parent 963085d18c
commit 5df7dfcd71

View File

@ -166,7 +166,10 @@ export function compileScript(
scriptLang === 'tsx' ||
scriptSetupLang === 'ts' ||
scriptSetupLang === 'tsx'
const plugins: ParserPlugin[] = [...babelParserDefaultPlugins, 'jsx']
const plugins: ParserPlugin[] = [...babelParserDefaultPlugins]
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
plugins.push('jsx')
}
if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins)
if (isTS) plugins.push('typescript', 'decorators-legacy')