Skip to content

Commit 61f648e

Browse files
committed
fix: use jsxImportSource in optimizeDeps
1 parent a72dc8e commit 61f648e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix: use jsxImportSource in optimizeDeps
6+
57
## 3.1.0
68

79
- Support plugins via the new `plugins` options

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Options = {
4242

4343
const react = (_options?: Options): PluginOption[] => {
4444
const options = {
45-
jsxImportSource: _options?.jsxImportSource,
45+
jsxImportSource: _options?.jsxImportSource ?? "react",
4646
tsDecorators: _options?.tsDecorators,
4747
plugins: _options?.plugins
4848
? _options?.plugins.map((el): typeof el => [resolve(el[0]), el[1]])
@@ -55,7 +55,9 @@ const react = (_options?: Options): PluginOption[] => {
5555
apply: "serve",
5656
config: () => ({
5757
esbuild: false,
58-
optimizeDeps: { include: ["react/jsx-dev-runtime"] },
58+
optimizeDeps: {
59+
include: [`${options.jsxImportSource}/jsx-dev-runtime`],
60+
},
5961
}),
6062
resolveId: (id) => (id === runtimePublicPath ? id : undefined),
6163
load: (id) =>
@@ -80,7 +82,7 @@ const react = (_options?: Options): PluginOption[] => {
8082
development: true,
8183
useBuiltins: true,
8284
runtime: "automatic",
83-
importSource: options?.jsxImportSource,
85+
importSource: options.jsxImportSource,
8486
});
8587
if (!result) return;
8688

@@ -123,7 +125,7 @@ const react = (_options?: Options): PluginOption[] => {
123125
transformWithOptions(_id.split("?")[0], code, options, {
124126
useBuiltins: true,
125127
runtime: "automatic",
126-
importSource: options?.jsxImportSource,
128+
importSource: options.jsxImportSource,
127129
}),
128130
}
129131
: {
@@ -132,7 +134,7 @@ const react = (_options?: Options): PluginOption[] => {
132134
config: () => ({
133135
esbuild: {
134136
jsx: "automatic",
135-
jsxImportSource: options?.jsxImportSource,
137+
jsxImportSource: options.jsxImportSource,
136138
tsconfigRaw: {
137139
compilerOptions: { useDefineForClassFields: true },
138140
},

0 commit comments

Comments
 (0)