From: 小刘(liulinboyi) <814921718@qq.com> Date: Tue, 10 May 2022 01:20:18 +0000 (+0800) Subject: fix(compiler-sfc): remove the jsx from the babelParserPlugins when not match the... X-Git-Tag: v3.2.34-beta.1~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7d7a2410e58d3ae59ca3fcf619f332699209fc96;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): remove the jsx from the babelParserPlugins when not match the case of adding jsx (#5846) fix #5845 --- diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 7c84f29b3b..7c16bcc8f3 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -172,6 +172,12 @@ export function compileScript( const plugins: ParserPlugin[] = [] if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') { 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 (isTS) plugins.push('typescript', 'decorators-legacy')