@vitejs/plugin-react 5.1.1 → 5.1.3

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
@@ -19,9 +19,9 @@ export default defineConfig({
19
19
 
20
20
  ## Options
21
21
 
22
- ### include/exclude
22
+ ### include
23
23
 
24
- Includes `.js`, `.jsx`, `.ts` & `.tsx` and excludes `/node_modules/` by default. This option can be used to add fast refresh to `.mdx` files:
24
+ Includes `.js`, `.jsx`, `.ts` & `.tsx` 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,6 +36,22 @@ export default defineConfig({
36
36
  })
37
37
  ```
38
38
 
39
+ ### exclude
40
+
41
+ The default value is `/node_modules/`. You may use it to exclude JSX/TSX files that runs in a worker or are not React files.
42
+ Except if explicitly desired, you should keep `node_modules` in the exclude list:
43
+
44
+ ```js
45
+ import { defineConfig } from 'vite'
46
+ import react from '@vitejs/plugin-react'
47
+
48
+ export default defineConfig({
49
+ plugins: [
50
+ react({ exclude: [/\/pdf\//, /\.solid\.tsx$/, /\/node_modules\//] }),
51
+ ],
52
+ })
53
+ ```
54
+
39
55
  ### jsxImportSource
40
56
 
41
57
  Control where the JSX factory is imported from. By default, this is inferred from `jsxImportSource` from corresponding a tsconfig file for a transformed file.
package/dist/index.d.ts CHANGED
@@ -3,7 +3,18 @@ import { ParserOptions, TransformOptions } from "@babel/core";
3
3
 
4
4
  //#region src/index.d.ts
5
5
  interface Options {
6
+ /**
7
+ * Can be used to process extra files like `.mdx`
8
+ * @example include: /\.(mdx|js|jsx|ts|tsx)$/
9
+ * @default /\.[tj]sx?$/
10
+ */
6
11
  include?: string | RegExp | Array<string | RegExp>;
12
+ /**
13
+ * Can be used to exclude JSX/TSX files that runs in a worker or are not React files.
14
+ * Except if explicitly desired, you should keep node_modules in the exclude list
15
+ * @example exclude: [/\/pdf\//, /\.solid\.tsx$/, /\/node_modules\//]
16
+ * @default /\/node_modules\//
17
+ */
7
18
  exclude?: string | RegExp | Array<string | RegExp>;
8
19
  /**
9
20
  * Control where the JSX factory is imported from.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ import { readFileSync } from "node:fs";
1
2
  import { dirname, join } from "node:path";
2
3
  import { fileURLToPath } from "node:url";
3
- import { readFileSync } from "node:fs";
4
+ import { exactRegex, makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
4
5
  import * as vite from "vite";
5
6
  import { createFilter } from "vite";
6
- import { exactRegex, makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
7
7
 
8
8
  //#region ../common/refresh-utils.ts
9
9
  const runtimePublicPath = "/@react-refresh";
@@ -101,7 +101,7 @@ function viteReact(opts = {}) {
101
101
  let projectRoot = process.cwd();
102
102
  let skipFastRefresh = true;
103
103
  let base;
104
- let isFullBundle = false;
104
+ let isBundledDev = false;
105
105
  let runPluginOverrides;
106
106
  let staticBabelOptions;
107
107
  const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
@@ -142,7 +142,7 @@ function viteReact(opts = {}) {
142
142
  configResolved(config) {
143
143
  runningInVite = true;
144
144
  base = config.base;
145
- if (config.experimental.fullBundleMode) isFullBundle = true;
145
+ if (config.experimental.bundledDev) isBundledDev = true;
146
146
  projectRoot = config.root;
147
147
  isProduction = config.isProduction;
148
148
  skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
@@ -184,14 +184,14 @@ function viteReact(opts = {}) {
184
184
  return newBabelOptions;
185
185
  })();
186
186
  const plugins = [...babelOptions.plugins];
187
- let reactCompilerPlugin$1 = getReactCompilerPlugin(plugins);
188
- if (reactCompilerPlugin$1 && ssr) {
189
- plugins.splice(plugins.indexOf(reactCompilerPlugin$1), 1);
190
- reactCompilerPlugin$1 = void 0;
187
+ let reactCompilerPlugin = getReactCompilerPlugin(plugins);
188
+ if (reactCompilerPlugin && ssr) {
189
+ plugins.splice(plugins.indexOf(reactCompilerPlugin), 1);
190
+ reactCompilerPlugin = void 0;
191
191
  }
192
- if (Array.isArray(reactCompilerPlugin$1) && reactCompilerPlugin$1[1]?.compilationMode === "annotation" && !compilerAnnotationRE.test(code)) {
193
- plugins.splice(plugins.indexOf(reactCompilerPlugin$1), 1);
194
- reactCompilerPlugin$1 = void 0;
192
+ if (Array.isArray(reactCompilerPlugin) && reactCompilerPlugin[1]?.compilationMode === "annotation" && !compilerAnnotationRE.test(code)) {
193
+ plugins.splice(plugins.indexOf(reactCompilerPlugin), 1);
194
+ reactCompilerPlugin = void 0;
195
195
  }
196
196
  const isJSX = filepath.endsWith("x");
197
197
  const useFastRefresh = !(isRolldownVite || skipFastRefresh) && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
@@ -208,7 +208,7 @@ function viteReact(opts = {}) {
208
208
  root: projectRoot,
209
209
  filename: id,
210
210
  sourceFileName: filepath,
211
- retainLines: reactCompilerPlugin$1 ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
211
+ retainLines: reactCompilerPlugin ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
212
212
  parserOpts: {
213
213
  ...babelOptions.parserOpts,
214
214
  sourceType: "module",
@@ -284,12 +284,12 @@ function viteReact(opts = {}) {
284
284
  if (userConfig.server?.hmr === false) return { oxc: { jsx: { refresh: false } } };
285
285
  }
286
286
  };
287
- const viteReactRefreshFullBundleMode = {
287
+ const viteReactRefreshBundledDevMode = {
288
288
  name: "vite:react-refresh-fbm",
289
289
  enforce: "pre",
290
290
  transformIndexHtml: {
291
291
  handler() {
292
- if (!skipFastRefresh && isFullBundle) return [{
292
+ if (!skipFastRefresh && isBundledDev) return [{
293
293
  tag: "script",
294
294
  attrs: { type: "module" },
295
295
  children: getPreambleCode(base)
@@ -329,7 +329,7 @@ function viteReact(opts = {}) {
329
329
  }
330
330
  },
331
331
  transformIndexHtml() {
332
- if (!skipFastRefresh && !isFullBundle) return [{
332
+ if (!skipFastRefresh && !isBundledDev) return [{
333
333
  tag: "script",
334
334
  attrs: { type: "module" },
335
335
  children: getPreambleCode(base)
@@ -341,12 +341,12 @@ function viteReact(opts = {}) {
341
341
  ...isRolldownVite ? [
342
342
  viteRefreshWrapper,
343
343
  viteConfigPost,
344
- viteReactRefreshFullBundleMode
344
+ viteReactRefreshBundledDevMode
345
345
  ] : [],
346
346
  viteReactRefresh,
347
347
  virtualPreamblePlugin({
348
348
  name: "@vitejs/plugin-react/preamble",
349
- isEnabled: () => !skipFastRefresh && !isFullBundle
349
+ isEnabled: () => !skipFastRefresh && !isBundledDev
350
350
  })
351
351
  ];
352
352
  }
package/package.json CHANGED
@@ -1,24 +1,33 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "5.1.1",
4
- "license": "MIT",
5
- "author": "Evan You",
3
+ "version": "5.1.3",
6
4
  "description": "The default Vite plugin for React projects",
7
5
  "keywords": [
8
- "vite",
9
- "vite-plugin",
10
- "react",
11
6
  "babel",
7
+ "fast refresh",
8
+ "react",
12
9
  "react-refresh",
13
- "fast refresh"
10
+ "vite",
11
+ "vite-plugin"
14
12
  ],
13
+ "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/vitejs/vite-plugin-react/issues"
16
+ },
17
+ "license": "MIT",
18
+ "author": "Evan You",
15
19
  "contributors": [
16
20
  "Alec Larson",
17
21
  "Arnaud Barré"
18
22
  ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/vitejs/vite-plugin-react.git",
26
+ "directory": "packages/plugin-react"
27
+ },
19
28
  "files": [
20
- "types",
21
- "dist"
29
+ "dist",
30
+ "types"
22
31
  ],
23
32
  "type": "module",
24
33
  "exports": {
@@ -31,35 +40,38 @@
31
40
  "prepublishOnly": "npm run build",
32
41
  "test-unit": "vitest run"
33
42
  },
34
- "engines": {
35
- "node": "^20.19.0 || >=22.12.0"
36
- },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/vitejs/vite-plugin-react.git",
40
- "directory": "packages/plugin-react"
41
- },
42
- "bugs": {
43
- "url": "https://github.com/vitejs/vite-plugin-react/issues"
44
- },
45
- "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
46
43
  "dependencies": {
47
- "@babel/core": "^7.28.5",
44
+ "@babel/core": "^7.29.0",
48
45
  "@babel/plugin-transform-react-jsx-self": "^7.27.1",
49
46
  "@babel/plugin-transform-react-jsx-source": "^7.27.1",
50
- "@rolldown/pluginutils": "1.0.0-beta.47",
47
+ "@rolldown/pluginutils": "1.0.0-rc.2",
51
48
  "@types/babel__core": "^7.20.5",
52
49
  "react-refresh": "^0.18.0"
53
50
  },
54
- "peerDependencies": {
55
- "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
56
- },
57
51
  "devDependencies": {
58
52
  "@vitejs/react-common": "workspace:*",
59
53
  "babel-plugin-react-compiler": "19.1.0-rc.3",
60
- "react": "^19.2.0",
61
- "react-dom": "^19.2.0",
62
- "rolldown": "1.0.0-beta.47",
63
- "tsdown": "^0.16.1"
54
+ "react": "^19.2.4",
55
+ "react-dom": "^19.2.4",
56
+ "rolldown": "1.0.0-rc.2",
57
+ "tsdown": "^0.20.1"
58
+ },
59
+ "peerDependencies": {
60
+ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
61
+ },
62
+ "engines": {
63
+ "node": "^20.19.0 || >=22.12.0"
64
+ },
65
+ "compatiblePackages": {
66
+ "schemaVersion": 1,
67
+ "rolldown": {
68
+ "type": "compatible",
69
+ "versions": "^1.0.0-beta.44",
70
+ "note": "You can use Rolldown's built-in feature directly."
71
+ },
72
+ "rollup": {
73
+ "type": "incompatible",
74
+ "reason": "Uses Rolldown-specific APIs or Vite-specific APIs"
75
+ }
64
76
  }
65
77
  }