fix(compiler-sfc): remove the jsx from the babelParserPlugins when not match the case of adding jsx (#5846)

fix #5845
This commit is contained in:
小刘(liulinboyi) 2022-05-10 09:20:18 +08:00 committed by GitHub
parent 16939241b0
commit 7d7a2410e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,6 +172,12 @@ export function compileScript(
const plugins: ParserPlugin[] = [] const plugins: ParserPlugin[] = []
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') { if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
plugins.push('jsx') plugins.push('jsx')
} else {
// If don't match the case of adding jsx, should remove the jsx from the babelParserPlugins
if (options.babelParserPlugins)
options.babelParserPlugins = options.babelParserPlugins.filter(
n => n !== 'jsx'
)
} }
if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins) if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins)
if (isTS) plugins.push('typescript', 'decorators-legacy') if (isTS) plugins.push('typescript', 'decorators-legacy')