Skip to content

Commit

Permalink
fix(plugin-react): turn off jsx for .ts (#5198)
Browse files Browse the repository at this point in the history
Fixes #5102
  • Loading branch information
hyrious committed Oct 5, 2021
1 parent 1b47e2b commit 916f9d3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default function viteReact(opts: Options = {}): PluginOption[] {

const parserPlugins: typeof userParserPlugins = [
...userParserPlugins,
'jsx',
'importMeta',
// This plugin is applied before esbuild transforms the code,
// so we need to enable some stage 3 syntax that is supported in
Expand All @@ -108,6 +107,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
'classPrivateMethods'
]

if (!id.endsWith('.ts')) {
parserPlugins.push('jsx')
}

const isTypeScript = /\.tsx?$/.test(id)
if (isTypeScript) {
parserPlugins.push('typescript')
Expand Down

0 comments on commit 916f9d3

Please sign in to comment.