@@ -24,6 +24,8 @@ export interface OxcOptions extends OxcTransformOptions {
24
24
include ?: string | RegExp | string [ ] | RegExp [ ]
25
25
exclude ?: string | RegExp | string [ ] | RegExp [ ]
26
26
jsxInject ?: string
27
+ jsxInclude ?: string | RegExp | string [ ] | RegExp [ ]
28
+ jsxExclude ?: string | RegExp | string [ ] | RegExp [ ]
27
29
}
28
30
29
31
export async function transformWithOxc (
@@ -176,9 +178,26 @@ export async function transformWithOxc(
176
178
177
179
export function oxcPlugin ( config : ResolvedConfig ) : Plugin {
178
180
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
180
189
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
+ )
182
201
183
202
let server : ViteDevServer
184
203
@@ -189,6 +208,20 @@ export function oxcPlugin(config: ResolvedConfig): Plugin {
189
208
} ,
190
209
async transform ( code , id ) {
191
210
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
+
192
225
const result = await transformWithOxc (
193
226
this ,
194
227
code ,
0 commit comments