@vitejs/plugin-react 4.6.0 → 5.0.0-beta.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
@@ -21,7 +21,7 @@ export default defineConfig({
21
21
 
22
22
  ### include/exclude
23
23
 
24
- Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
24
+ Includes `.js`, `.jsx`, `.ts` & `.tsx` and excludes `/node_modules/` by default. This option can be used to add fast refresh to `.mdx` files:
25
25
 
26
26
  ```js
27
27
  import { defineConfig } from 'vite'
@@ -36,8 +36,6 @@ export default defineConfig({
36
36
  })
37
37
  ```
38
38
 
39
- > `node_modules` are never processed by this plugin (but esbuild will)
40
-
41
39
  ### jsxImportSource
42
40
 
43
41
  Control where the JSX factory is imported from. Default to `'react'`
package/dist/index.d.ts CHANGED
@@ -1,38 +1,35 @@
1
- import { TransformOptions, ParserOptions } from '@babel/core';
2
- import { PluginOption, ResolvedConfig } from 'vite';
1
+ import { Plugin, ResolvedConfig } from "vite";
2
+ import { ParserOptions, TransformOptions } from "@babel/core";
3
3
 
4
+ //#region src/index.d.ts
4
5
  interface Options {
5
- include?: string | RegExp | Array<string | RegExp>;
6
- exclude?: string | RegExp | Array<string | RegExp>;
7
- /**
8
- * Control where the JSX factory is imported from.
9
- * https://esbuild.github.io/api/#jsx-import-source
10
- * @default 'react'
11
- */
12
- jsxImportSource?: string;
13
- /**
14
- * Note: Skipping React import with classic runtime is not supported from v4
15
- * @default "automatic"
16
- */
17
- jsxRuntime?: 'classic' | 'automatic';
18
- /**
19
- * Babel configuration applied in both dev and prod.
20
- */
21
- babel?: BabelOptions | ((id: string, options: {
22
- ssr?: boolean;
23
- }) => BabelOptions);
24
- /**
25
- * React Fast Refresh runtime URL prefix.
26
- * Useful in a module federation context to enable HMR by specifying
27
- * the host application URL in the Vite config of a remote application.
28
- * @example
29
- * reactRefreshHost: 'http://localhost:3000'
30
- */
31
- reactRefreshHost?: string;
32
- /**
33
- * If set, disables the recommendation to use `@vitejs/plugin-react-oxc`
34
- */
35
- disableOxcRecommendation?: boolean;
6
+ include?: string | RegExp | Array<string | RegExp>;
7
+ exclude?: string | RegExp | Array<string | RegExp>;
8
+ /**
9
+ * Control where the JSX factory is imported from.
10
+ * https://esbuild.github.io/api/#jsx-import-source
11
+ * @default 'react'
12
+ */
13
+ jsxImportSource?: string;
14
+ /**
15
+ * Note: Skipping React import with classic runtime is not supported from v4
16
+ * @default "automatic"
17
+ */
18
+ jsxRuntime?: 'classic' | 'automatic';
19
+ /**
20
+ * Babel configuration applied in both dev and prod.
21
+ */
22
+ babel?: BabelOptions | ((id: string, options: {
23
+ ssr?: boolean;
24
+ }) => BabelOptions);
25
+ /**
26
+ * React Fast Refresh runtime URL prefix.
27
+ * Useful in a module federation context to enable HMR by specifying
28
+ * the host application URL in the Vite config of a remote application.
29
+ * @example
30
+ * reactRefreshHost: 'http://localhost:3000'
31
+ */
32
+ reactRefreshHost?: string;
36
33
  }
37
34
  type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
38
35
  /**
@@ -40,28 +37,28 @@ type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'source
40
37
  * an `api.reactBabel` method.
41
38
  */
42
39
  interface ReactBabelOptions extends BabelOptions {
43
- plugins: Extract<BabelOptions['plugins'], any[]>;
44
- presets: Extract<BabelOptions['presets'], any[]>;
45
- overrides: Extract<BabelOptions['overrides'], any[]>;
46
- parserOpts: ParserOptions & {
47
- plugins: Extract<ParserOptions['plugins'], any[]>;
48
- };
40
+ plugins: Extract<BabelOptions['plugins'], any[]>;
41
+ presets: Extract<BabelOptions['presets'], any[]>;
42
+ overrides: Extract<BabelOptions['overrides'], any[]>;
43
+ parserOpts: ParserOptions & {
44
+ plugins: Extract<ParserOptions['plugins'], any[]>;
45
+ };
49
46
  }
50
47
  type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
51
48
  type ReactBabelHookContext = {
52
- ssr: boolean;
53
- id: string;
49
+ ssr: boolean;
50
+ id: string;
54
51
  };
55
52
  type ViteReactPluginApi = {
56
- /**
57
- * Manipulate the Babel options of `@vitejs/plugin-react`
58
- */
59
- reactBabel?: ReactBabelHook;
53
+ /**
54
+ * Manipulate the Babel options of `@vitejs/plugin-react`
55
+ */
56
+ reactBabel?: ReactBabelHook;
60
57
  };
61
- declare function viteReact(opts?: Options): PluginOption[];
58
+ declare function viteReact(opts?: Options): Plugin[];
62
59
  declare namespace viteReact {
63
- var preambleCode: string;
60
+ var preambleCode: string;
64
61
  }
65
-
66
- export = viteReact;
67
- export type { BabelOptions, Options, ReactBabelOptions, ViteReactPluginApi };
62
+ declare function viteReactForCjs(this: unknown, options: Options): Plugin[];
63
+ //#endregion
64
+ export { BabelOptions, Options, ReactBabelOptions, ViteReactPluginApi, viteReact as default, viteReactForCjs as "module.exports" };
package/dist/index.js ADDED
@@ -0,0 +1,359 @@
1
+ import { dirname, join } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { readFileSync } from "node:fs";
4
+ import * as vite from "vite";
5
+ import { createFilter } from "vite";
6
+ import { exactRegex, makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
7
+
8
+ //#region ../common/refresh-utils.ts
9
+ const runtimePublicPath = "/@react-refresh";
10
+ const reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
11
+ const refreshContentRE = /\$RefreshReg\$\(/;
12
+ const preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice(1)}";
13
+ injectIntoGlobalHook(window);
14
+ window.$RefreshReg$ = () => {};
15
+ window.$RefreshSig$ = () => (type) => type;`;
16
+ const getPreambleCode = (base) => preambleCode.replace("__BASE__", base);
17
+ const avoidSourceMapOption = Symbol();
18
+ function addRefreshWrapper(code, map, pluginName, id, reactRefreshHost = "") {
19
+ const hasRefresh = refreshContentRE.test(code);
20
+ const onlyReactComp = !hasRefresh && reactCompRE.test(code);
21
+ const normalizedMap = map === avoidSourceMapOption ? null : map;
22
+ if (!hasRefresh && !onlyReactComp) return {
23
+ code,
24
+ map: normalizedMap
25
+ };
26
+ const avoidSourceMap = map === avoidSourceMapOption;
27
+ const newMap = typeof normalizedMap === "string" ? JSON.parse(normalizedMap) : normalizedMap;
28
+ let newCode = code;
29
+ if (hasRefresh) {
30
+ const refreshHead = removeLineBreaksIfNeeded(`let prevRefreshReg;
31
+ let prevRefreshSig;
32
+
33
+ if (import.meta.hot && !inWebWorker) {
34
+ if (!window.$RefreshReg$) {
35
+ throw new Error(
36
+ "${pluginName} can't detect preamble. Something is wrong."
37
+ );
38
+ }
39
+
40
+ prevRefreshReg = window.$RefreshReg$;
41
+ prevRefreshSig = window.$RefreshSig$;
42
+ window.$RefreshReg$ = RefreshRuntime.getRefreshReg(${JSON.stringify(id)});
43
+ window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
44
+ }
45
+
46
+ `, avoidSourceMap);
47
+ newCode = `${refreshHead}${newCode}
48
+
49
+ if (import.meta.hot && !inWebWorker) {
50
+ window.$RefreshReg$ = prevRefreshReg;
51
+ window.$RefreshSig$ = prevRefreshSig;
52
+ }
53
+ `;
54
+ if (newMap) newMap.mappings = ";".repeat(16) + newMap.mappings;
55
+ }
56
+ const sharedHead = removeLineBreaksIfNeeded(`import * as RefreshRuntime from "${reactRefreshHost}${runtimePublicPath}";
57
+ const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
58
+
59
+ `, avoidSourceMap);
60
+ newCode = `${sharedHead}${newCode}
61
+
62
+ if (import.meta.hot && !inWebWorker) {
63
+ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
64
+ RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(id)}, currentExports);
65
+ import.meta.hot.accept((nextExports) => {
66
+ if (!nextExports) return;
67
+ const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(id)}, currentExports, nextExports);
68
+ if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
69
+ });
70
+ });
71
+ }
72
+ `;
73
+ if (newMap) newMap.mappings = ";;;" + newMap.mappings;
74
+ return {
75
+ code: newCode,
76
+ map: newMap
77
+ };
78
+ }
79
+ function removeLineBreaksIfNeeded(code, enabled) {
80
+ return enabled ? code.replace(/\n/g, "") : code;
81
+ }
82
+
83
+ //#endregion
84
+ //#region ../common/warning.ts
85
+ const silenceUseClientWarning = (userConfig) => ({ rollupOptions: { onwarn(warning, defaultHandler) {
86
+ if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) return;
87
+ if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) return;
88
+ if (userConfig.build?.rollupOptions?.onwarn) userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
89
+ else defaultHandler(warning);
90
+ } } });
91
+
92
+ //#endregion
93
+ //#region src/index.ts
94
+ const _dirname = dirname(fileURLToPath(import.meta.url));
95
+ const refreshRuntimePath = join(_dirname, "refresh-runtime.js");
96
+ let babel;
97
+ async function loadBabel() {
98
+ if (!babel) babel = await import("@babel/core");
99
+ return babel;
100
+ }
101
+ const defaultIncludeRE = /\.[tj]sx?$/;
102
+ const defaultExcludeRE = /\/node_modules\//;
103
+ const tsRE = /\.tsx?$/;
104
+ function viteReact(opts = {}) {
105
+ const include = opts.include ?? defaultIncludeRE;
106
+ const exclude = opts.exclude ?? defaultExcludeRE;
107
+ const filter = createFilter(include, exclude);
108
+ const jsxImportSource = opts.jsxImportSource ?? "react";
109
+ const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
110
+ const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
111
+ const isRolldownVite = "rolldownVersion" in vite;
112
+ let runningInVite = false;
113
+ let isProduction = true;
114
+ let projectRoot = process.cwd();
115
+ let skipFastRefresh = true;
116
+ let runPluginOverrides;
117
+ let staticBabelOptions;
118
+ const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
119
+ const viteBabel = {
120
+ name: "vite:react-babel",
121
+ enforce: "pre",
122
+ config(_userConfig, { command }) {
123
+ if ("rolldownVersion" in vite) if (opts.jsxRuntime === "classic") return { oxc: {
124
+ jsx: {
125
+ runtime: "classic",
126
+ refresh: command === "serve",
127
+ development: false
128
+ },
129
+ jsxRefreshInclude: include,
130
+ jsxRefreshExclude: exclude
131
+ } };
132
+ else return {
133
+ oxc: {
134
+ jsx: {
135
+ runtime: "automatic",
136
+ importSource: jsxImportSource,
137
+ refresh: command === "serve"
138
+ },
139
+ jsxRefreshInclude: include,
140
+ jsxRefreshExclude: exclude
141
+ },
142
+ optimizeDeps: { rollupOptions: { jsx: { mode: "automatic" } } }
143
+ };
144
+ if (opts.jsxRuntime === "classic") return { esbuild: { jsx: "transform" } };
145
+ else return {
146
+ esbuild: {
147
+ jsx: "automatic",
148
+ jsxImportSource
149
+ },
150
+ optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
151
+ };
152
+ },
153
+ configResolved(config) {
154
+ runningInVite = true;
155
+ projectRoot = config.root;
156
+ isProduction = config.isProduction;
157
+ skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
158
+ const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(defined);
159
+ if (hooks.length > 0) runPluginOverrides = (babelOptions, context) => {
160
+ hooks.forEach((hook) => hook(babelOptions, context, config));
161
+ };
162
+ else if (typeof opts.babel !== "function") {
163
+ staticBabelOptions = createBabelOptions(opts.babel);
164
+ if (canSkipBabel(staticBabelOptions.plugins, staticBabelOptions) && skipFastRefresh && (opts.jsxRuntime === "classic" ? isProduction : true)) delete viteBabel.transform;
165
+ }
166
+ },
167
+ options(options) {
168
+ if (!runningInVite) {
169
+ options.jsx = {
170
+ mode: opts.jsxRuntime,
171
+ importSource: opts.jsxImportSource
172
+ };
173
+ return options;
174
+ }
175
+ },
176
+ transform: {
177
+ filter: { id: {
178
+ include: makeIdFiltersToMatchWithQuery(include),
179
+ exclude: makeIdFiltersToMatchWithQuery(exclude)
180
+ } },
181
+ async handler(code, id, options) {
182
+ const [filepath] = id.split("?");
183
+ if (!filter(filepath)) return;
184
+ const ssr = options?.ssr === true;
185
+ const babelOptions = (() => {
186
+ if (staticBabelOptions) return staticBabelOptions;
187
+ const newBabelOptions = createBabelOptions(typeof opts.babel === "function" ? opts.babel(id, { ssr }) : opts.babel);
188
+ runPluginOverrides?.(newBabelOptions, {
189
+ id,
190
+ ssr
191
+ });
192
+ return newBabelOptions;
193
+ })();
194
+ const plugins = [...babelOptions.plugins];
195
+ const isJSX = filepath.endsWith("x");
196
+ const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
197
+ if (useFastRefresh && !isRolldownVite) plugins.push([await loadPlugin("react-refresh/babel"), { skipEnvCheck: true }]);
198
+ if (opts.jsxRuntime === "classic" && isJSX) {
199
+ if (!isProduction) plugins.push(await loadPlugin("@babel/plugin-transform-react-jsx-self"), await loadPlugin("@babel/plugin-transform-react-jsx-source"));
200
+ }
201
+ if (canSkipBabel(plugins, babelOptions)) return;
202
+ const parserPlugins = [...babelOptions.parserOpts.plugins];
203
+ if (!filepath.endsWith(".ts")) parserPlugins.push("jsx");
204
+ if (tsRE.test(filepath)) parserPlugins.push("typescript");
205
+ const babel$1 = await loadBabel();
206
+ const result = await babel$1.transformAsync(code, {
207
+ ...babelOptions,
208
+ root: projectRoot,
209
+ filename: id,
210
+ sourceFileName: filepath,
211
+ retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
212
+ parserOpts: {
213
+ ...babelOptions.parserOpts,
214
+ sourceType: "module",
215
+ allowAwaitOutsideFunction: true,
216
+ plugins: parserPlugins
217
+ },
218
+ generatorOpts: {
219
+ ...babelOptions.generatorOpts,
220
+ importAttributesKeyword: "with",
221
+ decoratorsBeforeExport: true
222
+ },
223
+ plugins,
224
+ sourceMaps: true
225
+ });
226
+ if (result) {
227
+ if (!useFastRefresh) return {
228
+ code: result.code,
229
+ map: result.map
230
+ };
231
+ return addRefreshWrapper(result.code, result.map, "@vitejs/plugin-react", id, opts.reactRefreshHost);
232
+ }
233
+ }
234
+ }
235
+ };
236
+ const viteRefreshWrapper = {
237
+ name: "vite:react:refresh-wrapper",
238
+ apply: "serve",
239
+ transform: isRolldownVite ? {
240
+ filter: { id: {
241
+ include: makeIdFiltersToMatchWithQuery(include),
242
+ exclude: makeIdFiltersToMatchWithQuery(exclude)
243
+ } },
244
+ handler(code, id, options) {
245
+ const ssr = options?.ssr === true;
246
+ const [filepath] = id.split("?");
247
+ const isJSX = filepath.endsWith("x");
248
+ const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime));
249
+ if (!useFastRefresh) return;
250
+ const { code: newCode } = addRefreshWrapper(code, avoidSourceMapOption, "@vitejs/plugin-react", id);
251
+ return {
252
+ code: newCode,
253
+ map: null
254
+ };
255
+ }
256
+ } : void 0
257
+ };
258
+ const viteConfigPost = {
259
+ name: "vite:react:config-post",
260
+ enforce: "post",
261
+ config(userConfig) {
262
+ if (userConfig.server?.hmr === false) return { oxc: { jsx: { refresh: false } } };
263
+ }
264
+ };
265
+ const dependencies = [
266
+ "react",
267
+ "react-dom",
268
+ jsxImportDevRuntime,
269
+ jsxImportRuntime
270
+ ];
271
+ const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : [];
272
+ const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
273
+ if (reactCompilerPlugin != null) {
274
+ const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
275
+ dependencies.push(reactCompilerRuntimeModule);
276
+ }
277
+ const viteReactRefresh = {
278
+ name: "vite:react-refresh",
279
+ enforce: "pre",
280
+ config: (userConfig) => ({
281
+ build: silenceUseClientWarning(userConfig),
282
+ optimizeDeps: { include: dependencies }
283
+ }),
284
+ resolveId: {
285
+ filter: { id: exactRegex(runtimePublicPath) },
286
+ handler(id) {
287
+ if (id === runtimePublicPath) return id;
288
+ }
289
+ },
290
+ load: {
291
+ filter: { id: exactRegex(runtimePublicPath) },
292
+ handler(id) {
293
+ if (id === runtimePublicPath) return readFileSync(refreshRuntimePath, "utf-8").replace(/__README_URL__/g, "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react");
294
+ }
295
+ },
296
+ transformIndexHtml(_, config) {
297
+ if (!skipFastRefresh) return [{
298
+ tag: "script",
299
+ attrs: { type: "module" },
300
+ children: getPreambleCode(config.server.config.base)
301
+ }];
302
+ }
303
+ };
304
+ return [
305
+ viteBabel,
306
+ viteRefreshWrapper,
307
+ viteConfigPost,
308
+ viteReactRefresh
309
+ ];
310
+ }
311
+ viteReact.preambleCode = preambleCode;
312
+ function viteReactForCjs(options) {
313
+ return viteReact.call(this, options);
314
+ }
315
+ Object.assign(viteReactForCjs, { default: viteReactForCjs });
316
+ function canSkipBabel(plugins, babelOptions) {
317
+ return !(plugins.length || babelOptions.presets.length || babelOptions.configFile || babelOptions.babelrc);
318
+ }
319
+ const loadedPlugin = /* @__PURE__ */ new Map();
320
+ function loadPlugin(path) {
321
+ const cached = loadedPlugin.get(path);
322
+ if (cached) return cached;
323
+ const promise = import(path).then((module) => {
324
+ const value = module.default || module;
325
+ loadedPlugin.set(path, value);
326
+ return value;
327
+ });
328
+ loadedPlugin.set(path, promise);
329
+ return promise;
330
+ }
331
+ function createBabelOptions(rawOptions) {
332
+ const babelOptions = {
333
+ babelrc: false,
334
+ configFile: false,
335
+ ...rawOptions
336
+ };
337
+ babelOptions.plugins ||= [];
338
+ babelOptions.presets ||= [];
339
+ babelOptions.overrides ||= [];
340
+ babelOptions.parserOpts ||= {};
341
+ babelOptions.parserOpts.plugins ||= [];
342
+ return babelOptions;
343
+ }
344
+ function defined(value) {
345
+ return value !== void 0;
346
+ }
347
+ function getReactCompilerPlugin(plugins) {
348
+ return plugins.find((p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler");
349
+ }
350
+ function getReactCompilerRuntimeModule(plugin) {
351
+ let moduleName = "react/compiler-runtime";
352
+ if (Array.isArray(plugin)) {
353
+ if (plugin[1]?.target === "17" || plugin[1]?.target === "18") moduleName = "react-compiler-runtime";
354
+ }
355
+ return moduleName;
356
+ }
357
+
358
+ //#endregion
359
+ export { viteReact as default, viteReactForCjs as "module.exports" };
@@ -545,6 +545,21 @@ function isLikelyComponentType(type) {
545
545
  }
546
546
  }
547
547
 
548
+ function isCompoundComponent(type) {
549
+ if (!isPlainObject(type)) return false
550
+ for (const key in type) {
551
+ if (!isLikelyComponentType(type[key])) return false
552
+ }
553
+ return true
554
+ }
555
+
556
+ function isPlainObject(obj) {
557
+ return (
558
+ Object.prototype.toString.call(obj) === '[object Object]' &&
559
+ (obj.constructor === Object || obj.constructor === undefined)
560
+ )
561
+ }
562
+
548
563
  /**
549
564
  * Plugin utils
550
565
  */
@@ -565,6 +580,13 @@ export function registerExportsForReactRefresh(filename, moduleExports) {
565
580
  // The register function has an identity check to not register twice the same component,
566
581
  // so this is safe to not used the same key here.
567
582
  register(exportValue, filename + ' export ' + key)
583
+ } else if (isCompoundComponent(exportValue)) {
584
+ for (const subKey in exportValue) {
585
+ register(
586
+ exportValue[subKey],
587
+ filename + ' export ' + key + '-' + subKey,
588
+ )
589
+ }
568
590
  }
569
591
  }
570
592
  }
@@ -618,6 +640,7 @@ export function validateRefreshBoundaryAndEnqueueUpdate(
618
640
  (key, value) => {
619
641
  hasExports = true
620
642
  if (isLikelyComponentType(value)) return true
643
+ if (isCompoundComponent(value)) return true
621
644
  return prevExports[key] === nextExports[key]
622
645
  },
623
646
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "4.6.0",
3
+ "version": "5.0.0-beta.0",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "The default Vite plugin for React projects",
@@ -20,24 +20,15 @@
20
20
  "dist"
21
21
  ],
22
22
  "type": "module",
23
- "main": "./dist/index.cjs",
24
- "module": "./dist/index.mjs",
25
- "types": "./dist/index.d.mts",
26
- "exports": {
27
- ".": {
28
- "import": "./dist/index.mjs",
29
- "require": "./dist/index.cjs"
30
- }
31
- },
23
+ "exports": "./dist/index.js",
32
24
  "scripts": {
33
- "dev": "unbuild --stub",
34
- "build": "unbuild && pnpm run patch-cjs && tsx scripts/copyRefreshRuntime.ts",
35
- "patch-cjs": "tsx ../../scripts/patchCJS.ts",
25
+ "dev": "tsdown --watch",
26
+ "build": "tsdown",
36
27
  "prepublishOnly": "npm run build",
37
28
  "test-unit": "vitest run"
38
29
  },
39
30
  "engines": {
40
- "node": "^14.18.0 || >=16.0.0"
31
+ "node": "^20.19.0 || >=22.12.0"
41
32
  },
42
33
  "repository": {
43
34
  "type": "git",
@@ -49,23 +40,23 @@
49
40
  },
50
41
  "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
51
42
  "dependencies": {
52
- "@babel/core": "^7.27.4",
43
+ "@babel/core": "^7.28.0",
53
44
  "@babel/plugin-transform-react-jsx-self": "^7.27.1",
54
45
  "@babel/plugin-transform-react-jsx-source": "^7.27.1",
55
- "@rolldown/pluginutils": "1.0.0-beta.19",
46
+ "@rolldown/pluginutils": "1.0.0-beta.29",
56
47
  "@types/babel__core": "^7.20.5",
57
48
  "react-refresh": "^0.17.0"
58
49
  },
59
50
  "peerDependencies": {
60
- "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0-beta.0"
51
+ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
61
52
  },
62
53
  "devDependencies": {
63
54
  "@vitejs/react-common": "workspace:*",
64
55
  "babel-plugin-react-compiler": "19.1.0-rc.2",
65
56
  "react": "^19.1.0",
66
57
  "react-dom": "^19.1.0",
67
- "rolldown": "1.0.0-beta.19",
68
- "unbuild": "^3.5.0",
58
+ "rolldown": "1.0.0-beta.29",
59
+ "tsdown": "^0.13.0",
69
60
  "vitest": "^3.2.4"
70
61
  }
71
62
  }