From 7d7a2410e58d3ae59ca3fcf619f332699209fc96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=88=98=28liulinboyi=29?= <814921718@qq.com> Date: Tue, 10 May 2022 09:20:18 +0800 Subject: [PATCH] fix(compiler-sfc): remove the jsx from the babelParserPlugins when not match the case of adding jsx (#5846) fix #5845 --- packages/compiler-sfc/src/compileScript.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 7c84f29b..7c16bcc8 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')