Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions packages/vite/src/node/plugins/oxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,27 @@ export function setOxcTransformOptionsFromTsconfigOptions(
// when both the normal options and tsconfig is set,
// we want to prioritize the normal options
if (
oxcOptions.jsx === undefined ||
(typeof oxcOptions.jsx === 'object' && oxcOptions.jsx.runtime === undefined)
tsCompilerOptions.jsx === 'preserve' &&
(oxcOptions.jsx === undefined ||
(typeof oxcOptions.jsx === 'object' &&
oxcOptions.jsx.runtime === undefined))
) {
if (tsCompilerOptions.jsx === 'preserve') {
oxcOptions.jsx = 'preserve'
} else {
const jsxOptions: OxcJsxOptions = { ...oxcOptions.jsx }
oxcOptions.jsx = 'preserve'
}
if (oxcOptions.jsx !== 'preserve') {
const jsxOptions: OxcJsxOptions = { ...oxcOptions.jsx }

if (tsCompilerOptions.jsxFactory) {
jsxOptions.pragma ??= tsCompilerOptions.jsxFactory
}
if (tsCompilerOptions.jsxFragmentFactory) {
jsxOptions.pragmaFrag ??= tsCompilerOptions.jsxFragmentFactory
}
if (tsCompilerOptions.jsxImportSource) {
jsxOptions.importSource ??= tsCompilerOptions.jsxImportSource
}
if (tsCompilerOptions.jsxFactory) {
jsxOptions.pragma ??= tsCompilerOptions.jsxFactory
}
if (tsCompilerOptions.jsxFragmentFactory) {
jsxOptions.pragmaFrag ??= tsCompilerOptions.jsxFragmentFactory
}
if (tsCompilerOptions.jsxImportSource) {
jsxOptions.importSource ??= tsCompilerOptions.jsxImportSource
}

if (!jsxOptions.runtime) {
switch (tsCompilerOptions.jsx) {
case 'react':
jsxOptions.runtime = 'classic'
Expand All @@ -99,10 +102,11 @@ export function setOxcTransformOptionsFromTsconfigOptions(
default:
break
}

oxcOptions.jsx = jsxOptions
}

oxcOptions.jsx = jsxOptions
}

if (oxcOptions.decorator?.legacy === undefined) {
const experimentalDecorators = tsCompilerOptions.experimentalDecorators
if (experimentalDecorators !== undefined) {
Expand Down
Loading