@@ -24,6 +24,8 @@ export interface OxcOptions extends OxcTransformOptions {
2424 include ?: string | RegExp | string [ ] | RegExp [ ]
2525 exclude ?: string | RegExp | string [ ] | RegExp [ ]
2626 jsxInject ?: string
27+ jsxInclude ?: string | RegExp | string [ ] | RegExp [ ]
28+ jsxExclude ?: string | RegExp | string [ ] | RegExp [ ]
2729}
2830
2931export async function transformWithOxc (
@@ -176,9 +178,26 @@ export async function transformWithOxc(
176178
177179export function oxcPlugin ( config : ResolvedConfig ) : Plugin {
178180 const options = config . oxc as OxcOptions
179- const { jsxInject, include, exclude, ...oxcTransformOptions } = options
181+ const {
182+ jsxInject,
183+ include,
184+ exclude,
185+ jsxInclude,
186+ jsxExclude,
187+ ...oxcTransformOptions
188+ } = options
180189
181- const filter = createFilter ( include || / \. ( m ? t s | [ j t ] s x ) $ / , exclude || / \. j s $ / )
190+ const defaultInclude = Array . isArray ( include )
191+ ? include
192+ : [ include || / \. ( m ? t s | [ j t ] s x ) $ / ]
193+ const filter = createFilter (
194+ defaultInclude . concat ( jsxInclude || [ ] ) ,
195+ exclude || / \. j s $ / ,
196+ )
197+ const jsxFilter = createFilter (
198+ jsxInclude || / \. j s x $ / ,
199+ jsxExclude || / \. ( m ? [ j t ] s | t s x ) $ / ,
200+ )
182201
183202 let server : ViteDevServer
184203
@@ -189,6 +208,20 @@ export function oxcPlugin(config: ResolvedConfig): Plugin {
189208 } ,
190209 async transform ( code , id ) {
191210 if ( filter ( id ) || filter ( cleanUrl ( id ) ) ) {
211+ // disable refresh at ssr
212+ if (
213+ this . environment . config . consumer === 'server' &&
214+ oxcTransformOptions . jsx ?. refresh
215+ ) {
216+ oxcTransformOptions . jsx . refresh = false
217+ }
218+ if (
219+ ( jsxFilter ( id ) || jsxFilter ( cleanUrl ( id ) ) ) &&
220+ ! oxcTransformOptions . lang
221+ ) {
222+ oxcTransformOptions . lang = 'jsx'
223+ }
224+
192225 const result = await transformWithOxc (
193226 this ,
194227 code ,
0 commit comments