@vitejs/plugin-react-swc 3.10.1 → 3.10.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 +8 -0
- package/index.cjs +32 -2
- package/index.d.ts +4 -0
- package/index.mjs +9 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -117,6 +117,14 @@ react({
|
|
|
117
117
|
})
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
### disableOxcRecommendation
|
|
121
|
+
|
|
122
|
+
If set, disables the recommendation to use `@vitejs/plugin-react-oxc` (which is shown when `rolldown-vite` is detected and neither `swc` plugins are used nor the `swc` options are mutated).
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
react({ disableOxcRecommendation: true })
|
|
126
|
+
```
|
|
127
|
+
|
|
120
128
|
## Consistent components exports
|
|
121
129
|
|
|
122
130
|
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).
|
package/index.cjs
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
|
|
1
24
|
// src/index.ts
|
|
2
25
|
var import_node_fs = require("fs");
|
|
3
26
|
var import_node_path = require("path");
|
|
@@ -111,6 +134,7 @@ var silenceUseClientWarning = (userConfig) => ({
|
|
|
111
134
|
});
|
|
112
135
|
|
|
113
136
|
// src/index.ts
|
|
137
|
+
var vite = __toESM(require("vite"), 1);
|
|
114
138
|
var import_pluginutils = require("@rolldown/pluginutils");
|
|
115
139
|
var import_meta = {};
|
|
116
140
|
var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
@@ -126,7 +150,8 @@ var react = (_options) => {
|
|
|
126
150
|
devTarget: (_options == null ? void 0 : _options.devTarget) ?? "es2020",
|
|
127
151
|
parserConfig: _options == null ? void 0 : _options.parserConfig,
|
|
128
152
|
reactRefreshHost: _options == null ? void 0 : _options.reactRefreshHost,
|
|
129
|
-
useAtYourOwnRisk_mutateSwcOptions: _options == null ? void 0 : _options.useAtYourOwnRisk_mutateSwcOptions
|
|
153
|
+
useAtYourOwnRisk_mutateSwcOptions: _options == null ? void 0 : _options.useAtYourOwnRisk_mutateSwcOptions,
|
|
154
|
+
disableOxcRecommendation: _options == null ? void 0 : _options.disableOxcRecommendation
|
|
130
155
|
};
|
|
131
156
|
return [
|
|
132
157
|
{
|
|
@@ -158,7 +183,7 @@ var react = (_options) => {
|
|
|
158
183
|
oxc: false,
|
|
159
184
|
optimizeDeps: {
|
|
160
185
|
include: [`${options.jsxImportSource}/jsx-dev-runtime`],
|
|
161
|
-
esbuildOptions: { jsx: "automatic" }
|
|
186
|
+
..."rolldownVersion" in vite ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
|
|
162
187
|
}
|
|
163
188
|
}),
|
|
164
189
|
configResolved(config) {
|
|
@@ -171,6 +196,11 @@ var react = (_options) => {
|
|
|
171
196
|
"[vite:react-swc] The MDX plugin should be placed before this plugin"
|
|
172
197
|
);
|
|
173
198
|
}
|
|
199
|
+
if ("rolldownVersion" in vite && !options.plugins && !options.useAtYourOwnRisk_mutateSwcOptions && !options.disableOxcRecommendation) {
|
|
200
|
+
config.logger.warn(
|
|
201
|
+
"[vite:react-swc] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown"
|
|
202
|
+
);
|
|
203
|
+
}
|
|
174
204
|
},
|
|
175
205
|
transformIndexHtml: (_, config) => {
|
|
176
206
|
if (!hmrDisabled) {
|
package/index.d.ts
CHANGED
|
@@ -45,6 +45,10 @@ type Options = {
|
|
|
45
45
|
* feature doesn't work is not fun, so we won't provide support for it, hence the name `useAtYourOwnRisk`
|
|
46
46
|
*/
|
|
47
47
|
useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void;
|
|
48
|
+
/**
|
|
49
|
+
* If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
|
|
50
|
+
*/
|
|
51
|
+
disableOxcRecommendation?: boolean;
|
|
48
52
|
};
|
|
49
53
|
declare const react: (_options?: Options) => PluginOption[];
|
|
50
54
|
export default react;
|
package/index.mjs
CHANGED
|
@@ -113,6 +113,7 @@ var silenceUseClientWarning = (userConfig) => ({
|
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
// src/index.ts
|
|
116
|
+
import * as vite from "vite";
|
|
116
117
|
import { exactRegex } from "@rolldown/pluginutils";
|
|
117
118
|
var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
118
119
|
var resolve = createRequire(
|
|
@@ -127,7 +128,8 @@ var react = (_options) => {
|
|
|
127
128
|
devTarget: (_options == null ? void 0 : _options.devTarget) ?? "es2020",
|
|
128
129
|
parserConfig: _options == null ? void 0 : _options.parserConfig,
|
|
129
130
|
reactRefreshHost: _options == null ? void 0 : _options.reactRefreshHost,
|
|
130
|
-
useAtYourOwnRisk_mutateSwcOptions: _options == null ? void 0 : _options.useAtYourOwnRisk_mutateSwcOptions
|
|
131
|
+
useAtYourOwnRisk_mutateSwcOptions: _options == null ? void 0 : _options.useAtYourOwnRisk_mutateSwcOptions,
|
|
132
|
+
disableOxcRecommendation: _options == null ? void 0 : _options.disableOxcRecommendation
|
|
131
133
|
};
|
|
132
134
|
return [
|
|
133
135
|
{
|
|
@@ -159,7 +161,7 @@ var react = (_options) => {
|
|
|
159
161
|
oxc: false,
|
|
160
162
|
optimizeDeps: {
|
|
161
163
|
include: [`${options.jsxImportSource}/jsx-dev-runtime`],
|
|
162
|
-
esbuildOptions: { jsx: "automatic" }
|
|
164
|
+
..."rolldownVersion" in vite ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
|
|
163
165
|
}
|
|
164
166
|
}),
|
|
165
167
|
configResolved(config) {
|
|
@@ -172,6 +174,11 @@ var react = (_options) => {
|
|
|
172
174
|
"[vite:react-swc] The MDX plugin should be placed before this plugin"
|
|
173
175
|
);
|
|
174
176
|
}
|
|
177
|
+
if ("rolldownVersion" in vite && !options.plugins && !options.useAtYourOwnRisk_mutateSwcOptions && !options.disableOxcRecommendation) {
|
|
178
|
+
config.logger.warn(
|
|
179
|
+
"[vite:react-swc] We recommend switching to `@vitejs/plugin-react-oxc` for improved performance as no swc plugins are used. More information at https://vite.dev/rolldown"
|
|
180
|
+
);
|
|
181
|
+
}
|
|
175
182
|
},
|
|
176
183
|
transformIndexHtml: (_, config) => {
|
|
177
184
|
if (!hmrDisabled) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-react-swc",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
|
|
6
6
|
"description": "Speed up your Vite dev server with SWC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rolldown/pluginutils": "1.0.0-beta.
|
|
27
|
-
"@swc/core": "^1.11.
|
|
26
|
+
"@rolldown/pluginutils": "1.0.0-beta.11",
|
|
27
|
+
"@swc/core": "^1.11.31"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"vite": "^4 || ^5 || ^6"
|
|
30
|
+
"vite": "^4 || ^5 || ^6 || ^7.0.0-beta.0"
|
|
31
31
|
},
|
|
32
32
|
"main": "index.cjs",
|
|
33
33
|
"types": "index.d.ts",
|