Skip to content

Commit e6eb30a

Browse files
authored
fix: merge tsconfig jsx options even when oxc.jsx.runtime is set (#376)
1 parent 4056cc6 commit e6eb30a

File tree

1 file changed

+21
-17
lines changed
  • packages/vite/src/node/plugins

1 file changed

+21
-17
lines changed

packages/vite/src/node/plugins/oxc.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,27 @@ export function setOxcTransformOptionsFromTsconfigOptions(
6363
// when both the normal options and tsconfig is set,
6464
// we want to prioritize the normal options
6565
if (
66-
oxcOptions.jsx === undefined ||
67-
(typeof oxcOptions.jsx === 'object' && oxcOptions.jsx.runtime === undefined)
66+
tsCompilerOptions.jsx === 'preserve' &&
67+
(oxcOptions.jsx === undefined ||
68+
(typeof oxcOptions.jsx === 'object' &&
69+
oxcOptions.jsx.runtime === undefined))
6870
) {
69-
if (tsCompilerOptions.jsx === 'preserve') {
70-
oxcOptions.jsx = 'preserve'
71-
} else {
72-
const jsxOptions: OxcJsxOptions = { ...oxcOptions.jsx }
71+
oxcOptions.jsx = 'preserve'
72+
}
73+
if (oxcOptions.jsx !== 'preserve') {
74+
const jsxOptions: OxcJsxOptions = { ...oxcOptions.jsx }
7375

74-
if (tsCompilerOptions.jsxFactory) {
75-
jsxOptions.pragma ??= tsCompilerOptions.jsxFactory
76-
}
77-
if (tsCompilerOptions.jsxFragmentFactory) {
78-
jsxOptions.pragmaFrag ??= tsCompilerOptions.jsxFragmentFactory
79-
}
80-
if (tsCompilerOptions.jsxImportSource) {
81-
jsxOptions.importSource ??= tsCompilerOptions.jsxImportSource
82-
}
76+
if (tsCompilerOptions.jsxFactory) {
77+
jsxOptions.pragma ??= tsCompilerOptions.jsxFactory
78+
}
79+
if (tsCompilerOptions.jsxFragmentFactory) {
80+
jsxOptions.pragmaFrag ??= tsCompilerOptions.jsxFragmentFactory
81+
}
82+
if (tsCompilerOptions.jsxImportSource) {
83+
jsxOptions.importSource ??= tsCompilerOptions.jsxImportSource
84+
}
8385

86+
if (!jsxOptions.runtime) {
8487
switch (tsCompilerOptions.jsx) {
8588
case 'react':
8689
jsxOptions.runtime = 'classic'
@@ -99,10 +102,11 @@ export function setOxcTransformOptionsFromTsconfigOptions(
99102
default:
100103
break
101104
}
102-
103-
oxcOptions.jsx = jsxOptions
104105
}
106+
107+
oxcOptions.jsx = jsxOptions
105108
}
109+
106110
if (oxcOptions.decorator?.legacy === undefined) {
107111
const experimentalDecorators = tsCompilerOptions.experimentalDecorators
108112
if (experimentalDecorators !== undefined) {

0 commit comments

Comments
 (0)