@@ -103,6 +103,7 @@ import { createIdResolver } from './idResolver'
103
103
import { runnerImport } from './ssr/runnerImport'
104
104
import { getAdditionalAllowedHosts } from './server/middlewares/hostCheck'
105
105
import { convertEsbuildPluginToRolldownPlugin } from './optimizer/pluginConverter'
106
+ import { type OxcOptions , convertEsbuildConfigToOxcConfig } from './plugins/oxc'
106
107
107
108
const debug = createDebugger ( 'vite:config' , { depth : 10 } )
108
109
const promisifiedRealpath = promisify ( fs . realpath )
@@ -354,6 +355,11 @@ export interface UserConfig extends DefaultEnvironmentOptions {
354
355
* Or set to `false` to disable esbuild.
355
356
*/
356
357
esbuild ?: ESBuildOptions | false
358
+ /**
359
+ * Transform options to pass to esbuild.
360
+ * Or set to `false` to disable OXC.
361
+ */
362
+ oxc ?: OxcOptions | false
357
363
/**
358
364
* Specify additional picomatch patterns to be treated as static assets.
359
365
*/
@@ -596,6 +602,7 @@ export interface ResolvedConfig
596
602
css : ResolvedCSSOptions
597
603
json : Required < JsonOptions >
598
604
esbuild : ESBuildOptions | false
605
+ oxc : OxcOptions | false
599
606
server : ResolvedServerOptions
600
607
dev : ResolvedDevEnvironmentOptions
601
608
/** @experimental */
@@ -1553,6 +1560,17 @@ export async function resolveConfig(
1553
1560
1554
1561
const preview = resolvePreviewOptions ( config . preview , server )
1555
1562
1563
+ let oxc : OxcOptions | false | undefined = config . oxc
1564
+ if ( config . esbuild ) {
1565
+ if ( config . oxc ) {
1566
+ logger . warn (
1567
+ `Found esbuild and oxc options, will use oxc and ignore esbuild at transformer.` ,
1568
+ )
1569
+ } else {
1570
+ oxc = convertEsbuildConfigToOxcConfig ( config . esbuild , logger )
1571
+ }
1572
+ }
1573
+
1556
1574
resolved = {
1557
1575
configFile : configFile ? normalizePath ( configFile ) : undefined ,
1558
1576
configFileDependencies : configFileDependencies . map ( ( name ) =>
@@ -1574,13 +1592,27 @@ export async function resolveConfig(
1574
1592
plugins : userPlugins , // placeholder to be replaced
1575
1593
css : resolveCSSOptions ( config . css ) ,
1576
1594
json : mergeWithDefaults ( configDefaults . json , config . json ?? { } ) ,
1595
+ // preserve esbuild for buildEsbuildPlugin
1577
1596
esbuild :
1578
1597
config . esbuild === false
1579
1598
? false
1580
1599
: {
1581
1600
jsxDev : ! isProduction ,
1582
1601
...config . esbuild ,
1583
1602
} ,
1603
+ oxc :
1604
+ oxc === false
1605
+ ? false
1606
+ : {
1607
+ ...oxc ,
1608
+ jsx :
1609
+ typeof oxc ?. jsx === 'string'
1610
+ ? oxc . jsx
1611
+ : {
1612
+ development : oxc ?. jsx ?. development ?? ! isProduction ,
1613
+ ...oxc ?. jsx ,
1614
+ } ,
1615
+ } ,
1584
1616
server,
1585
1617
builder,
1586
1618
preview,
0 commit comments