Skip to content

Commit

Permalink
chore: fix oxc option convertion and reduce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Nov 22, 2024
1 parent ed4f448 commit 8a8a506
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/vite/src/node/plugins/oxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export async function transformWithOxc(
resolvedOptions.jsx.runtime = 'automatic'
break
case 'preserve':
ctx.warn('The tsconfig jsx preserve is not supported by oxc')
if (lang === 'tsx') {
ctx.warn('The tsconfig jsx preserve is not supported by oxc')
}
break
default:
break
Expand Down Expand Up @@ -287,9 +289,7 @@ export function convertEsbuildConfigToOxcConfig(
oxcOptions.jsx!.importSource = esbuildTransformOptions.jsxImportSource
}
if (esbuildTransformOptions.loader) {
if (
['.js', '.jsx', '.ts', 'tsx'].includes(esbuildTransformOptions.loader)
) {
if (['js', 'jsx', 'ts', 'tsx'].includes(esbuildTransformOptions.loader)) {
oxcOptions.lang = esbuildTransformOptions.loader as
| 'js'
| 'jsx'
Expand All @@ -310,7 +310,12 @@ export function convertEsbuildConfigToOxcConfig(
case false:
oxcOptions.sourcemap = esbuildTransformOptions.sourcemap
break

case 'external':
oxcOptions.sourcemap = true
break
// ignore it because it's not supported by esbuild `transform`
case 'linked':
break
default:
logger.warn(
`The esbuild sourcemap ${esbuildTransformOptions.sourcemap} is not supported by oxc`,
Expand Down

0 comments on commit 8a8a506

Please sign in to comment.