From 8a8a50635e526e89ecb19882fe5f7608a0a02ee3 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:42:25 +0900 Subject: [PATCH] chore: fix oxc option convertion and reduce warnings --- packages/vite/src/node/plugins/oxc.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/plugins/oxc.ts b/packages/vite/src/node/plugins/oxc.ts index d7d5b03ec2f80e..81f5c37f3eab84 100644 --- a/packages/vite/src/node/plugins/oxc.ts +++ b/packages/vite/src/node/plugins/oxc.ts @@ -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 @@ -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' @@ -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`,