Skip to content

Commit f2b501c

Browse files
committed
Add support for oxc
1 parent d2d5681 commit f2b501c

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

src/index.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ function preactPlugin({
166166
name: "vite:preact-jsx",
167167
enforce: "pre",
168168
config() {
169+
const supportsRolldown =
170+
"meta" in this && this.meta && typeof this.meta === "object"
171+
? "rolldownVersion" in this.meta
172+
: false;
173+
const shouldUseRolldown = supportsRolldown && !useBabel;
174+
const shouldUseEsbuild = !shouldUseRolldown && !useBabel;
175+
const shouldUseOxc = !!shouldUseRolldown;
169176
return {
170177
build: {
171178
rollupOptions: {
@@ -191,14 +198,31 @@ function preactPlugin({
191198
},
192199
},
193200
},
194-
esbuild: useBabel
195-
? undefined
196-
: {
201+
oxc: shouldUseOxc
202+
? {
203+
jsx: {
204+
runtime: "automatic",
205+
importSource: jsxImportSource ?? "preact",
206+
},
207+
}
208+
: undefined,
209+
esbuild: shouldUseEsbuild
210+
? {
197211
jsx: "automatic",
198212
jsxImportSource: jsxImportSource ?? "preact",
199-
},
213+
}
214+
: undefined,
200215
optimizeDeps: {
201216
include: ["preact", "preact/jsx-runtime", "preact/jsx-dev-runtime"],
217+
rolldownOptions: shouldUseRolldown
218+
? {
219+
transform: {
220+
jsx: {
221+
runtime: "automatic",
222+
},
223+
},
224+
}
225+
: undefined,
202226
},
203227
};
204228
},

0 commit comments

Comments
 (0)