@@ -103,6 +103,7 @@ import { createIdResolver } from './idResolver'
103103import { runnerImport } from './ssr/runnerImport'
104104import { getAdditionalAllowedHosts } from './server/middlewares/hostCheck'
105105import { convertEsbuildPluginToRolldownPlugin } from './optimizer/pluginConverter'
106+ import { type OxcOptions , convertEsbuildConfigToOxcConfig } from './plugins/oxc'
106107
107108const debug = createDebugger ( 'vite:config' , { depth : 10 } )
108109const promisifiedRealpath = promisify ( fs . realpath )
@@ -354,6 +355,11 @@ export interface UserConfig extends DefaultEnvironmentOptions {
354355 * Or set to `false` to disable esbuild.
355356 */
356357 esbuild ?: ESBuildOptions | false
358+ /**
359+ * Transform options to pass to esbuild.
360+ * Or set to `false` to disable OXC.
361+ */
362+ oxc ?: OxcOptions | false
357363 /**
358364 * Specify additional picomatch patterns to be treated as static assets.
359365 */
@@ -596,6 +602,7 @@ export interface ResolvedConfig
596602 css : ResolvedCSSOptions
597603 json : Required < JsonOptions >
598604 esbuild : ESBuildOptions | false
605+ oxc : OxcOptions | false
599606 server : ResolvedServerOptions
600607 dev : ResolvedDevEnvironmentOptions
601608 /** @experimental */
@@ -1581,6 +1588,17 @@ export async function resolveConfig(
15811588
15821589 const preview = resolvePreviewOptions ( config . preview , server )
15831590
1591+ let oxc : OxcOptions | false | undefined = config . oxc
1592+ if ( config . esbuild ) {
1593+ if ( config . oxc ) {
1594+ logger . warn (
1595+ `Found esbuild and oxc options, will use oxc and ignore esbuild at transformer.` ,
1596+ )
1597+ } else {
1598+ oxc = convertEsbuildConfigToOxcConfig ( config . esbuild , logger )
1599+ }
1600+ }
1601+
15841602 resolved = {
15851603 configFile : configFile ? normalizePath ( configFile ) : undefined ,
15861604 configFileDependencies : configFileDependencies . map ( ( name ) =>
@@ -1602,13 +1620,27 @@ export async function resolveConfig(
16021620 plugins : userPlugins , // placeholder to be replaced
16031621 css : resolveCSSOptions ( config . css ) ,
16041622 json : mergeWithDefaults ( configDefaults . json , config . json ?? { } ) ,
1623+ // preserve esbuild for buildEsbuildPlugin
16051624 esbuild :
16061625 config . esbuild === false
16071626 ? false
16081627 : {
16091628 jsxDev : ! isProduction ,
16101629 ...config . esbuild ,
16111630 } ,
1631+ oxc :
1632+ oxc === false
1633+ ? false
1634+ : {
1635+ ...oxc ,
1636+ jsx :
1637+ typeof oxc ?. jsx === 'string'
1638+ ? oxc . jsx
1639+ : {
1640+ development : oxc ?. jsx ?. development ?? ! isProduction ,
1641+ ...oxc ?. jsx ,
1642+ } ,
1643+ } ,
16121644 server,
16131645 builder,
16141646 preview,
0 commit comments