Skip to content

Commit 47f6eaa

Browse files
committed
fix: use optimizeDeps.rollupOptions for rolldown-vite
1 parent c7124fb commit 47f6eaa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/plugin-react-swc/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
transform,
1313
} from '@swc/core'
1414
import type { PluginOption } from 'vite'
15+
import * as vite from 'vite'
1516
import {
1617
addRefreshWrapper,
1718
getPreambleCode,
@@ -124,7 +125,9 @@ const react = (_options?: Options): PluginOption[] => {
124125
oxc: false,
125126
optimizeDeps: {
126127
include: [`${options.jsxImportSource}/jsx-dev-runtime`],
127-
esbuildOptions: { jsx: 'automatic' },
128+
...('rolldownVersion' in vite
129+
? { rollupOptions: { jsx: { mode: 'automatic' } } }
130+
: { esbuildOptions: { jsx: 'automatic' } }),
128131
},
129132
}),
130133
configResolved(config) {

packages/plugin-react/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
157157
jsx: 'automatic',
158158
jsxImportSource: opts.jsxImportSource,
159159
},
160-
optimizeDeps: { esbuildOptions: { jsx: 'automatic' } },
160+
optimizeDeps:
161+
'rolldownVersion' in vite
162+
? { rollupOptions: { jsx: { mode: 'automatic' } } }
163+
: { esbuildOptions: { jsx: 'automatic' } },
161164
}
162165
}
163166
},

0 commit comments

Comments
 (0)