Browse Source

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

fix #5845
pull/5890/head
小刘(liulinboyi) 3 years ago
committed by GitHub
parent
commit
7d7a2410e5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/compiler-sfc/src/compileScript.ts

6
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')

Loading…
Cancel
Save