Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugin-react): turn off jsx for .ts (vitejs#5198)
Browse files Browse the repository at this point in the history
hyrious authored and aleclarson committed Nov 8, 2021

Verified

This commit was signed with the committer’s verified signature. The key has expired.
mmarchini mary marchini
1 parent c11871f commit d4dace1
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
@@ -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
@@ -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')

0 comments on commit d4dace1

Please sign in to comment.