Skip to content

Commit

Permalink
fix(sfc): only enable jsx parser plugin when explicitly using tsx
Browse files Browse the repository at this point in the history
fix #4106
  • Loading branch information
yyx990803 committed Jul 15, 2021
1 parent 963085d commit 5df7dfc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ export function compileScript(
scriptLang === 'tsx' ||
scriptSetupLang === 'ts' ||
scriptSetupLang === 'tsx'
const plugins: ParserPlugin[] = [...babelParserDefaultPlugins, 'jsx']
const plugins: ParserPlugin[] = [...babelParserDefaultPlugins]
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
plugins.push('jsx')
}
if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins)
if (isTS) plugins.push('typescript', 'decorators-legacy')

Expand Down

0 comments on commit 5df7dfc

Please sign in to comment.