Skip to content

Commit

Permalink
fix(plugin-react): turn off jsx for .ts (vitejs#5198)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored and aleclarson committed Oct 11, 2021
1 parent 8cfb62f commit 6f0de95
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 @@ -114,7 +114,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 @@ -125,6 +124,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 6f0de95

Please sign in to comment.