Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Commit 95291df

Browse files
committed
Include react/jsx-dev-runtime for dependencies optimisation when using automatic runtime [publish]
1 parent 1c93491 commit 95291df

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.0.3
4+
5+
Include `react/jsx-dev-runtime` for dependencies optimisation when using automatic runtime.
6+
37
## 2.0.2
48

59
Unpinned `@swc/core` to get new features (like TS instantiation expression) despite a [30mb bump of bundle size](https://github.com/swc-project/swc/issues/3899)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vite-plugin-swc-react-refresh",
33
"description": "Use the versatility of swc for development and the maturity of esbuild for production",
4-
"version": "2.0.2",
4+
"version": "2.0.3",
55
"license": "MIT",
66
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
77
"main": "src/swc-react-refresh.js",

src/swc-react-refresh.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ export const swcReactRefresh = (): PluginOption => ({
2323
define = config.esbuild.define;
2424
automaticRuntime = config.esbuild.jsx === "automatic";
2525
}
26-
config.esbuild = false;
26+
return automaticRuntime
27+
? {
28+
esbuild: false,
29+
optimizeDeps: { include: ["react/jsx-dev-runtime"] },
30+
}
31+
: { esbuild: false };
2732
},
2833
resolveId: (id) => (id === runtimePublicPath ? id : undefined),
2934
load: (id) =>
@@ -57,6 +62,7 @@ export const swcReactRefresh = (): PluginOption => ({
5762
});
5863

5964
if (
65+
!automaticRuntime &&
6066
result.code.includes("React.createElement") &&
6167
!importReactRE.test(result.code)
6268
) {

0 commit comments

Comments
 (0)