Skip to content

Commit 5df7dfc

Browse files
committed
fix(sfc): only enable jsx parser plugin when explicitly using tsx
fix #4106
1 parent 963085d commit 5df7dfc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/compiler-sfc/src/compileScript.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ export function compileScript(
166166
scriptLang === 'tsx' ||
167167
scriptSetupLang === 'ts' ||
168168
scriptSetupLang === 'tsx'
169-
const plugins: ParserPlugin[] = [...babelParserDefaultPlugins, 'jsx']
169+
const plugins: ParserPlugin[] = [...babelParserDefaultPlugins]
170+
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
171+
plugins.push('jsx')
172+
}
170173
if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins)
171174
if (isTS) plugins.push('typescript', 'decorators-legacy')
172175

0 commit comments

Comments
 (0)