]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): remove the jsx from the babelParserPlugins when not match the...
author小刘(liulinboyi) <814921718@qq.com>
Tue, 10 May 2022 01:20:18 +0000 (09:20 +0800)
committerGitHub <noreply@github.com>
Tue, 10 May 2022 01:20:18 +0000 (21:20 -0400)
fix #5845

packages/compiler-sfc/src/compileScript.ts

index 7c84f29b3b3fa26720e46c61a39b7065a7d0f309..7c16bcc8f372862058e0b51dc0b4a1b78b500e77 100644 (file)
@@ -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')