@vitejs/plugin-react-swc 3.10.1 → 3.11.0

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 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,33 +1,57 @@
1
- // src/index.ts
2
- var import_node_fs = require("fs");
3
- var import_node_path = require("path");
4
- var import_node_url = require("url");
5
- var import_node_module = require("module");
6
- var import_core = require("@swc/core");
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const node_fs = __toESM(require("node:fs"));
25
+ const node_path = __toESM(require("node:path"));
26
+ const node_url = __toESM(require("node:url"));
27
+ const node_module = __toESM(require("node:module"));
28
+ const __swc_core = __toESM(require("@swc/core"));
29
+ const vite = __toESM(require("vite"));
30
+ const __rolldown_pluginutils = __toESM(require("@rolldown/pluginutils"));
7
31
 
8
- // ../common/refresh-utils.ts
9
- var runtimePublicPath = "/@react-refresh";
10
- var reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
11
- var refreshContentRE = /\$RefreshReg\$\(/;
12
- var preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice(
13
- 1
14
- )}";
32
+ //#region ../common/refresh-utils.ts
33
+ const runtimePublicPath = "/@react-refresh";
34
+ const reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
35
+ const refreshContentRE = /\$RefreshReg\$\(/;
36
+ const preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice(1)}";
15
37
  injectIntoGlobalHook(window);
16
38
  window.$RefreshReg$ = () => {};
17
39
  window.$RefreshSig$ = () => (type) => type;`;
18
- var getPreambleCode = (base) => preambleCode.replace("__BASE__", base);
19
- var avoidSourceMapOption = Symbol();
40
+ const getPreambleCode = (base) => preambleCode.replace("__BASE__", base);
41
+ const avoidSourceMapOption = Symbol();
20
42
  function addRefreshWrapper(code, map, pluginName, id, reactRefreshHost = "") {
21
- const hasRefresh = refreshContentRE.test(code);
22
- const onlyReactComp = !hasRefresh && reactCompRE.test(code);
23
- const normalizedMap = map === avoidSourceMapOption ? null : map;
24
- if (!hasRefresh && !onlyReactComp) return { code, map: normalizedMap };
25
- const avoidSourceMap = map === avoidSourceMapOption;
26
- const newMap = typeof normalizedMap === "string" ? JSON.parse(normalizedMap) : normalizedMap;
27
- let newCode = code;
28
- if (hasRefresh) {
29
- const refreshHead = removeLineBreaksIfNeeded(
30
- `let prevRefreshReg;
43
+ const hasRefresh = refreshContentRE.test(code);
44
+ const onlyReactComp = !hasRefresh && reactCompRE.test(code);
45
+ const normalizedMap = map === avoidSourceMapOption ? null : map;
46
+ if (!hasRefresh && !onlyReactComp) return {
47
+ code,
48
+ map: normalizedMap
49
+ };
50
+ const avoidSourceMap = map === avoidSourceMapOption;
51
+ const newMap = typeof normalizedMap === "string" ? JSON.parse(normalizedMap) : normalizedMap;
52
+ let newCode = code;
53
+ if (hasRefresh) {
54
+ const refreshHead = removeLineBreaksIfNeeded(`let prevRefreshReg;
31
55
  let prevRefreshSig;
32
56
 
33
57
  if (import.meta.hot && !inWebWorker) {
@@ -43,244 +67,196 @@ if (import.meta.hot && !inWebWorker) {
43
67
  window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
44
68
  }
45
69
 
46
- `,
47
- avoidSourceMap
48
- );
49
- newCode = `${refreshHead}${newCode}
70
+ `, avoidSourceMap);
71
+ newCode = `${refreshHead}${newCode}
50
72
 
51
73
  if (import.meta.hot && !inWebWorker) {
52
74
  window.$RefreshReg$ = prevRefreshReg;
53
75
  window.$RefreshSig$ = prevRefreshSig;
54
76
  }
55
77
  `;
56
- if (newMap) {
57
- newMap.mappings = ";".repeat(16) + newMap.mappings;
58
- }
59
- }
60
- const sharedHead = removeLineBreaksIfNeeded(
61
- `import * as RefreshRuntime from "${reactRefreshHost}${runtimePublicPath}";
78
+ if (newMap) newMap.mappings = ";".repeat(16) + newMap.mappings;
79
+ }
80
+ const sharedHead = removeLineBreaksIfNeeded(`import * as RefreshRuntime from "${reactRefreshHost}${runtimePublicPath}";
62
81
  const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
63
82
 
64
- `,
65
- avoidSourceMap
66
- );
67
- newCode = `${sharedHead}${newCode}
83
+ `, avoidSourceMap);
84
+ newCode = `${sharedHead}${newCode}
68
85
 
69
86
  if (import.meta.hot && !inWebWorker) {
70
87
  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
71
- RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
72
- id
73
- )}, currentExports);
88
+ RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(id)}, currentExports);
74
89
  import.meta.hot.accept((nextExports) => {
75
90
  if (!nextExports) return;
76
- const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
77
- id
78
- )}, currentExports, nextExports);
91
+ const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(id)}, currentExports, nextExports);
79
92
  if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
80
93
  });
81
94
  });
82
95
  }
83
96
  `;
84
- if (newMap) {
85
- newMap.mappings = ";;;" + newMap.mappings;
86
- }
87
- return { code: newCode, map: newMap };
97
+ if (newMap) newMap.mappings = ";;;" + newMap.mappings;
98
+ return {
99
+ code: newCode,
100
+ map: newMap
101
+ };
88
102
  }
89
103
  function removeLineBreaksIfNeeded(code, enabled) {
90
- return enabled ? code.replace(/\n/g, "") : code;
104
+ return enabled ? code.replace(/\n/g, "") : code;
91
105
  }
92
106
 
93
- // ../common/warning.ts
94
- var silenceUseClientWarning = (userConfig) => ({
95
- rollupOptions: {
96
- onwarn(warning, defaultHandler) {
97
- var _a, _b;
98
- if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
99
- return;
100
- }
101
- if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
102
- return;
103
- }
104
- if ((_b = (_a = userConfig.build) == null ? void 0 : _a.rollupOptions) == null ? void 0 : _b.onwarn) {
105
- userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
106
- } else {
107
- defaultHandler(warning);
108
- }
109
- }
110
- }
111
- });
107
+ //#endregion
108
+ //#region ../common/warning.ts
109
+ const silenceUseClientWarning = (userConfig) => ({ rollupOptions: { onwarn(warning, defaultHandler) {
110
+ if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) return;
111
+ if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) return;
112
+ if (userConfig.build?.rollupOptions?.onwarn) userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
113
+ else defaultHandler(warning);
114
+ } } });
112
115
 
113
- // src/index.ts
114
- var import_pluginutils = require("@rolldown/pluginutils");
115
- var import_meta = {};
116
- var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
117
- var resolve = (0, import_node_module.createRequire)(
118
- typeof __filename !== "undefined" ? __filename : import_meta.url
119
- ).resolve;
120
- var react = (_options) => {
121
- let hmrDisabled = false;
122
- const options = {
123
- jsxImportSource: (_options == null ? void 0 : _options.jsxImportSource) ?? "react",
124
- tsDecorators: _options == null ? void 0 : _options.tsDecorators,
125
- plugins: (_options == null ? void 0 : _options.plugins) ? _options == null ? void 0 : _options.plugins.map((el) => [resolve(el[0]), el[1]]) : void 0,
126
- devTarget: (_options == null ? void 0 : _options.devTarget) ?? "es2020",
127
- parserConfig: _options == null ? void 0 : _options.parserConfig,
128
- reactRefreshHost: _options == null ? void 0 : _options.reactRefreshHost,
129
- useAtYourOwnRisk_mutateSwcOptions: _options == null ? void 0 : _options.useAtYourOwnRisk_mutateSwcOptions
130
- };
131
- return [
132
- {
133
- name: "vite:react-swc:resolve-runtime",
134
- apply: "serve",
135
- enforce: "pre",
136
- // Run before Vite default resolve to avoid syscalls
137
- resolveId: {
138
- filter: { id: (0, import_pluginutils.exactRegex)(runtimePublicPath) },
139
- handler: (id) => id === runtimePublicPath ? id : void 0
140
- },
141
- load: {
142
- filter: { id: (0, import_pluginutils.exactRegex)(runtimePublicPath) },
143
- handler: (id) => id === runtimePublicPath ? (0, import_node_fs.readFileSync)(
144
- (0, import_node_path.join)(_dirname, "refresh-runtime.js"),
145
- "utf-8"
146
- ).replace(
147
- /__README_URL__/g,
148
- "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc"
149
- ) : void 0
150
- }
151
- },
152
- {
153
- name: "vite:react-swc",
154
- apply: "serve",
155
- config: () => ({
156
- esbuild: false,
157
- // NOTE: oxc option only exists in rolldown-vite
158
- oxc: false,
159
- optimizeDeps: {
160
- include: [`${options.jsxImportSource}/jsx-dev-runtime`],
161
- esbuildOptions: { jsx: "automatic" }
162
- }
163
- }),
164
- configResolved(config) {
165
- if (config.server.hmr === false) hmrDisabled = true;
166
- const mdxIndex = config.plugins.findIndex(
167
- (p) => p.name === "@mdx-js/rollup"
168
- );
169
- if (mdxIndex !== -1 && mdxIndex > config.plugins.findIndex((p) => p.name === "vite:react-swc")) {
170
- throw new Error(
171
- "[vite:react-swc] The MDX plugin should be placed before this plugin"
172
- );
173
- }
174
- },
175
- transformIndexHtml: (_, config) => {
176
- if (!hmrDisabled) {
177
- return [
178
- {
179
- tag: "script",
180
- attrs: { type: "module" },
181
- children: getPreambleCode(config.server.config.base)
182
- }
183
- ];
184
- }
185
- },
186
- async transform(code, _id, transformOptions) {
187
- const id = _id.split("?")[0];
188
- const refresh = !(transformOptions == null ? void 0 : transformOptions.ssr) && !hmrDisabled;
189
- const result = await transformWithOptions(
190
- id,
191
- code,
192
- options.devTarget,
193
- options,
194
- {
195
- refresh,
196
- development: true,
197
- runtime: "automatic",
198
- importSource: options.jsxImportSource
199
- }
200
- );
201
- if (!result) return;
202
- if (!refresh) return result;
203
- return addRefreshWrapper(
204
- result.code,
205
- result.map,
206
- "@vitejs/plugin-react-swc",
207
- id,
208
- options.reactRefreshHost
209
- );
210
- }
211
- },
212
- options.plugins ? {
213
- name: "vite:react-swc",
214
- apply: "build",
215
- enforce: "pre",
216
- // Run before esbuild
217
- config: (userConfig) => ({
218
- build: silenceUseClientWarning(userConfig)
219
- }),
220
- transform: (code, _id) => transformWithOptions(_id.split("?")[0], code, "esnext", options, {
221
- runtime: "automatic",
222
- importSource: options.jsxImportSource
223
- })
224
- } : {
225
- name: "vite:react-swc",
226
- apply: "build",
227
- config: (userConfig) => ({
228
- build: silenceUseClientWarning(userConfig),
229
- esbuild: {
230
- jsx: "automatic",
231
- jsxImportSource: options.jsxImportSource,
232
- tsconfigRaw: {
233
- compilerOptions: { useDefineForClassFields: true }
234
- }
235
- }
236
- })
237
- }
238
- ];
116
+ //#endregion
117
+ //#region src/index.ts
118
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
119
+ const resolve = (0, node_module.createRequire)(typeof __filename !== "undefined" ? __filename : require("url").pathToFileURL(__filename).href).resolve;
120
+ const react = (_options) => {
121
+ let hmrDisabled = false;
122
+ const options = {
123
+ jsxImportSource: _options?.jsxImportSource ?? "react",
124
+ tsDecorators: _options?.tsDecorators,
125
+ plugins: _options?.plugins ? _options?.plugins.map((el) => [resolve(el[0]), el[1]]) : void 0,
126
+ devTarget: _options?.devTarget ?? "es2020",
127
+ parserConfig: _options?.parserConfig,
128
+ reactRefreshHost: _options?.reactRefreshHost,
129
+ useAtYourOwnRisk_mutateSwcOptions: _options?.useAtYourOwnRisk_mutateSwcOptions,
130
+ disableOxcRecommendation: _options?.disableOxcRecommendation
131
+ };
132
+ return [
133
+ {
134
+ name: "vite:react-swc:resolve-runtime",
135
+ apply: "serve",
136
+ enforce: "pre",
137
+ resolveId: {
138
+ filter: { id: (0, __rolldown_pluginutils.exactRegex)(runtimePublicPath) },
139
+ handler: (id) => id === runtimePublicPath ? id : void 0
140
+ },
141
+ load: {
142
+ filter: { id: (0, __rolldown_pluginutils.exactRegex)(runtimePublicPath) },
143
+ handler: (id) => id === runtimePublicPath ? (0, node_fs.readFileSync)((0, node_path.join)(_dirname, "refresh-runtime.js"), "utf-8").replace(/__README_URL__/g, "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc") : void 0
144
+ }
145
+ },
146
+ {
147
+ name: "vite:react-swc",
148
+ apply: "serve",
149
+ config: () => ({
150
+ esbuild: false,
151
+ oxc: false,
152
+ optimizeDeps: {
153
+ include: [`${options.jsxImportSource}/jsx-dev-runtime`],
154
+ ..."rolldownVersion" in vite ? { rollupOptions: { jsx: { mode: "automatic" } } } : { esbuildOptions: { jsx: "automatic" } }
155
+ }
156
+ }),
157
+ configResolved(config) {
158
+ if (config.server.hmr === false) hmrDisabled = true;
159
+ const mdxIndex = config.plugins.findIndex((p) => p.name === "@mdx-js/rollup");
160
+ if (mdxIndex !== -1 && mdxIndex > config.plugins.findIndex((p) => p.name === "vite:react-swc")) throw new Error("[vite:react-swc] The MDX plugin should be placed before this plugin");
161
+ if ("rolldownVersion" in vite && !options.plugins && !options.useAtYourOwnRisk_mutateSwcOptions && !options.disableOxcRecommendation) config.logger.warn("[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");
162
+ },
163
+ transformIndexHtml: (_, config) => {
164
+ if (!hmrDisabled) return [{
165
+ tag: "script",
166
+ attrs: { type: "module" },
167
+ children: getPreambleCode(config.server.config.base)
168
+ }];
169
+ },
170
+ async transform(code, _id, transformOptions) {
171
+ const id = _id.split("?")[0];
172
+ const refresh = !transformOptions?.ssr && !hmrDisabled;
173
+ const result = await transformWithOptions(id, code, options.devTarget, options, {
174
+ refresh,
175
+ development: true,
176
+ runtime: "automatic",
177
+ importSource: options.jsxImportSource
178
+ });
179
+ if (!result) return;
180
+ if (!refresh) return result;
181
+ return addRefreshWrapper(result.code, result.map, "@vitejs/plugin-react-swc", id, options.reactRefreshHost);
182
+ }
183
+ },
184
+ options.plugins ? {
185
+ name: "vite:react-swc",
186
+ apply: "build",
187
+ enforce: "pre",
188
+ config: (userConfig) => ({ build: silenceUseClientWarning(userConfig) }),
189
+ transform: (code, _id) => transformWithOptions(_id.split("?")[0], code, "esnext", options, {
190
+ runtime: "automatic",
191
+ importSource: options.jsxImportSource
192
+ })
193
+ } : {
194
+ name: "vite:react-swc",
195
+ apply: "build",
196
+ config: (userConfig) => ({
197
+ build: silenceUseClientWarning(userConfig),
198
+ esbuild: {
199
+ jsx: "automatic",
200
+ jsxImportSource: options.jsxImportSource,
201
+ tsconfigRaw: { compilerOptions: { useDefineForClassFields: true } }
202
+ }
203
+ })
204
+ }
205
+ ];
239
206
  };
240
- var transformWithOptions = async (id, code, target, options, reactConfig) => {
241
- const decorators = (options == null ? void 0 : options.tsDecorators) ?? false;
242
- const parser = options.parserConfig ? options.parserConfig(id) : id.endsWith(".tsx") ? { syntax: "typescript", tsx: true, decorators } : id.endsWith(".ts") || id.endsWith(".mts") ? { syntax: "typescript", tsx: false, decorators } : id.endsWith(".jsx") ? { syntax: "ecmascript", jsx: true } : id.endsWith(".mdx") ? (
243
- // JSX is required to trigger fast refresh transformations, even if MDX already transforms it
244
- { syntax: "ecmascript", jsx: true }
245
- ) : void 0;
246
- if (!parser) return;
247
- let result;
248
- try {
249
- const swcOptions = {
250
- filename: id,
251
- swcrc: false,
252
- configFile: false,
253
- sourceMaps: true,
254
- jsc: {
255
- target,
256
- parser,
257
- experimental: { plugins: options.plugins },
258
- transform: {
259
- useDefineForClassFields: true,
260
- react: reactConfig
261
- }
262
- }
263
- };
264
- if (options.useAtYourOwnRisk_mutateSwcOptions) {
265
- options.useAtYourOwnRisk_mutateSwcOptions(swcOptions);
266
- }
267
- result = await (0, import_core.transform)(code, swcOptions);
268
- } catch (e) {
269
- const message = e.message;
270
- const fileStartIndex = message.indexOf("\u256D\u2500[");
271
- if (fileStartIndex !== -1) {
272
- const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)\]/);
273
- if (match) {
274
- e.line = match[1];
275
- e.column = match[2];
276
- }
277
- }
278
- throw e;
279
- }
280
- return result;
207
+ const transformWithOptions = async (id, code, target, options, reactConfig) => {
208
+ const decorators = options?.tsDecorators ?? false;
209
+ const parser = options.parserConfig ? options.parserConfig(id) : id.endsWith(".tsx") ? {
210
+ syntax: "typescript",
211
+ tsx: true,
212
+ decorators
213
+ } : id.endsWith(".ts") || id.endsWith(".mts") ? {
214
+ syntax: "typescript",
215
+ tsx: false,
216
+ decorators
217
+ } : id.endsWith(".jsx") ? {
218
+ syntax: "ecmascript",
219
+ jsx: true
220
+ } : id.endsWith(".mdx") ? {
221
+ syntax: "ecmascript",
222
+ jsx: true
223
+ } : void 0;
224
+ if (!parser) return;
225
+ let result;
226
+ try {
227
+ const swcOptions = {
228
+ filename: id,
229
+ swcrc: false,
230
+ configFile: false,
231
+ sourceMaps: true,
232
+ jsc: {
233
+ target,
234
+ parser,
235
+ experimental: { plugins: options.plugins },
236
+ transform: {
237
+ useDefineForClassFields: true,
238
+ react: reactConfig
239
+ }
240
+ }
241
+ };
242
+ if (options.useAtYourOwnRisk_mutateSwcOptions) options.useAtYourOwnRisk_mutateSwcOptions(swcOptions);
243
+ result = await (0, __swc_core.transform)(code, swcOptions);
244
+ } catch (e) {
245
+ const message = e.message;
246
+ const fileStartIndex = message.indexOf("╭─[");
247
+ if (fileStartIndex !== -1) {
248
+ const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)\]/);
249
+ if (match) {
250
+ e.line = match[1];
251
+ e.column = match[2];
252
+ }
253
+ }
254
+ throw e;
255
+ }
256
+ return result;
281
257
  };
282
258
  var src_default = react;
283
259
 
284
- // <stdin>
260
+ //#endregion
285
261
  module.exports = src_default;
286
- module.exports.default = src_default;
262
+ module.exports.default = module.exports
package/index.d.cts ADDED
@@ -0,0 +1,57 @@
1
+ import { JscTarget, Options, ParserConfig } from "@swc/core";
2
+ import { Plugin } from "vite";
3
+
4
+ //#region src/index.d.ts
5
+ type Options$1 = {
6
+ /**
7
+ * Control where the JSX factory is imported from.
8
+ * @default "react"
9
+ */
10
+ jsxImportSource?: string;
11
+ /**
12
+ * Enable TypeScript decorators. Requires experimentalDecorators in tsconfig.
13
+ * @default false
14
+ */
15
+ tsDecorators?: boolean;
16
+ /**
17
+ * Use SWC plugins. Enable SWC at build time.
18
+ * @default undefined
19
+ */
20
+ plugins?: [string, Record<string, any>][];
21
+ /**
22
+ * Set the target for SWC in dev. This can avoid to down-transpile private class method for example.
23
+ * For production target, see https://vite.dev/config/build-options.html#build-target
24
+ * @default "es2020"
25
+ */
26
+ devTarget?: JscTarget;
27
+ /**
28
+ * Override the default include list (.ts, .tsx, .mts, .jsx, .mdx).
29
+ * This requires to redefine the config for any file you want to be included.
30
+ * If you want to trigger fast refresh on compiled JS, use `jsx: true`.
31
+ * Exclusion of node_modules should be handled by the function if needed.
32
+ */
33
+ parserConfig?: (id: string) => ParserConfig | undefined;
34
+ /**
35
+ * React Fast Refresh runtime URL prefix.
36
+ * Useful in a module federation context to enable HMR by specifying
37
+ * the host application URL in a Vite config of a remote application.
38
+ * @example
39
+ * reactRefreshHost: 'http://localhost:3000'
40
+ */
41
+ reactRefreshHost?: string;
42
+ /**
43
+ * The future of Vite is with OXC, and from the beginning this was a design choice
44
+ * to not exposed too many specialties from SWC so that Vite React users can move to
45
+ * another transformer later.
46
+ * Also debugging why some specific version of decorators with some other unstable/legacy
47
+ * feature doesn't work is not fun, so we won't provide support for it, hence the name `useAtYourOwnRisk`
48
+ */
49
+ useAtYourOwnRisk_mutateSwcOptions?: (options: Options) => void;
50
+ /**
51
+ * If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
52
+ */
53
+ disableOxcRecommendation?: boolean;
54
+ };
55
+ declare const react: (_options?: Options$1) => Plugin[];
56
+ //#endregion
57
+ export { react as default };