Skip to content

Commit 304b0c2

Browse files
fix: do not set jsxImportSource when using babel (#156)
* fix: do not set jsxImportSource when using babel * Apply suggestions from code review * revert: TS is dumb --------- Co-authored-by: Ryan Christian <[email protected]>
1 parent 890edb9 commit 304b0c2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function preactPlugin({
140140
babelOptions.parserOpts ||= {} as any;
141141
babelOptions.parserOpts.plugins ||= [];
142142

143-
let useBabel: boolean;
143+
let useBabel = typeof babel !== "undefined";
144144
const shouldTransform = createFilter(
145145
include || [/\.[cm]?[tj]sx?$/],
146146
exclude || [/node_modules/],
@@ -190,11 +190,12 @@ function preactPlugin({
190190
},
191191
},
192192
},
193-
// While this config is unconditional, it'll only be used if Babel is not
194-
esbuild: {
195-
jsx: "automatic",
196-
jsxImportSource: jsxImportSource ?? "preact",
197-
},
193+
esbuild: useBabel
194+
? undefined
195+
: {
196+
jsx: "automatic",
197+
jsxImportSource: jsxImportSource ?? "preact",
198+
},
198199
optimizeDeps: {
199200
include: ["preact", "preact/jsx-runtime", "preact/jsx-dev-runtime"],
200201
},
@@ -204,8 +205,7 @@ function preactPlugin({
204205
config = resolvedConfig;
205206
devToolsEnabled =
206207
devToolsEnabled ?? (!config.isProduction || devtoolsInProd);
207-
useBabel =
208-
!config.isProduction || devToolsEnabled || typeof babel !== "undefined";
208+
useBabel ||= !config.isProduction || !!devToolsEnabled;
209209
},
210210
async transform(code, url) {
211211
// Ignore query parameters, as in Vue SFC virtual modules.

0 commit comments

Comments
 (0)