@vitejs/plugin-react-swc 3.0.0-beta.0 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/index.cjs +5 -3
- package/index.mjs +5 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @vitejs/plugin-react-swc [](https://www.npmjs.com/package/@vitejs/plugin-react-swc)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Speed up your Vite dev server with [SWC](https://swc.rs/)
|
|
4
4
|
|
|
5
5
|
- ✅ A fast Fast Refresh (~20x faster than Babel)
|
|
6
6
|
- ✅ Enable [automatic JSX runtime](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
|
|
7
7
|
|
|
8
|
-
> ⚠️ This is
|
|
8
|
+
> ⚠️ This is a beta release for Vite 4, for the v2 named `vite-plugin-swc-react-refresh`, see the [v2 branch](https://github.com/vitejs/vite-plugin-react-swc/tree/v2).
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -38,6 +38,8 @@ This plugin is only used in development and aims to be kept simple to enable goo
|
|
|
38
38
|
|
|
39
39
|
## Consistent components exports
|
|
40
40
|
|
|
41
|
-
For React refresh to work, your file should only export React components. The best explanation I've read is the one from the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
|
|
41
|
+
For React refresh to work correctly, your file should only export React components. The best explanation I've read is the one from the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
|
|
42
|
+
|
|
43
|
+
If an incompatible change in exports is found, the module will be invalidated and HMR will propagate. To make it easier to export simple constants alongside your component, the module is only invalidated when their value changes.
|
|
42
44
|
|
|
43
45
|
You can catch mistakes and get more detailed warning with this [eslint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh).
|
package/index.cjs
CHANGED
|
@@ -34,9 +34,10 @@ injectIntoGlobalHook(window);
|
|
|
34
34
|
window.$RefreshReg$ = () => {};
|
|
35
35
|
window.$RefreshSig$ = () => (type) => type;`;
|
|
36
36
|
var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_path.dirname)((0, import_url.fileURLToPath)(import_meta.url));
|
|
37
|
+
var refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
37
38
|
var react = () => [
|
|
38
39
|
{
|
|
39
|
-
name: "
|
|
40
|
+
name: "vite:react-swc",
|
|
40
41
|
apply: "serve",
|
|
41
42
|
config: () => ({
|
|
42
43
|
esbuild: false,
|
|
@@ -86,8 +87,9 @@ var react = () => [
|
|
|
86
87
|
}
|
|
87
88
|
throw e;
|
|
88
89
|
}
|
|
89
|
-
if (!result.code
|
|
90
|
+
if ((transformOptions == null ? void 0 : transformOptions.ssr) || !refreshContentRE.test(result.code)) {
|
|
90
91
|
return result;
|
|
92
|
+
}
|
|
91
93
|
result.code = `import * as RefreshRuntime from "${runtimePublicPath}";
|
|
92
94
|
|
|
93
95
|
if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
@@ -114,7 +116,7 @@ var react = () => [
|
|
|
114
116
|
}
|
|
115
117
|
},
|
|
116
118
|
{
|
|
117
|
-
name: "
|
|
119
|
+
name: "vite:react-swc",
|
|
118
120
|
apply: "build",
|
|
119
121
|
config: () => ({
|
|
120
122
|
esbuild: {
|
package/index.mjs
CHANGED
|
@@ -9,9 +9,10 @@ injectIntoGlobalHook(window);
|
|
|
9
9
|
window.$RefreshReg$ = () => {};
|
|
10
10
|
window.$RefreshSig$ = () => (type) => type;`;
|
|
11
11
|
var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
var refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
12
13
|
var react = () => [
|
|
13
14
|
{
|
|
14
|
-
name: "
|
|
15
|
+
name: "vite:react-swc",
|
|
15
16
|
apply: "serve",
|
|
16
17
|
config: () => ({
|
|
17
18
|
esbuild: false,
|
|
@@ -61,8 +62,9 @@ var react = () => [
|
|
|
61
62
|
}
|
|
62
63
|
throw e;
|
|
63
64
|
}
|
|
64
|
-
if (!result.code
|
|
65
|
+
if ((transformOptions == null ? void 0 : transformOptions.ssr) || !refreshContentRE.test(result.code)) {
|
|
65
66
|
return result;
|
|
67
|
+
}
|
|
66
68
|
result.code = `import * as RefreshRuntime from "${runtimePublicPath}";
|
|
67
69
|
|
|
68
70
|
if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
@@ -89,7 +91,7 @@ var react = () => [
|
|
|
89
91
|
}
|
|
90
92
|
},
|
|
91
93
|
{
|
|
92
|
-
name: "
|
|
94
|
+
name: "vite:react-swc",
|
|
93
95
|
apply: "build",
|
|
94
96
|
config: () => ({
|
|
95
97
|
esbuild: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-react-swc",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"description": "Speed up your Vite dev server with SWC",
|
|
4
|
+
"version": "3.0.0-beta.2",
|
|
5
5
|
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:vitejs/vite-plugin-react-swc",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"module": "index.mjs",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"require": "index.cjs",
|
|
14
|
-
"types": "index.d.ts",
|
|
15
|
-
"import": "index.mjs"
|
|
13
|
+
"require": "./index.cjs",
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"import": "./index.mjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|