@vitejs/plugin-react 5.1.2 → 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 +18 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -10
- package/package.json +42 -30
package/README.md
CHANGED
|
@@ -19,9 +19,9 @@ export default defineConfig({
|
|
|
19
19
|
|
|
20
20
|
## Options
|
|
21
21
|
|
|
22
|
-
### include
|
|
22
|
+
### include
|
|
23
23
|
|
|
24
|
-
Includes `.js`, `.jsx`, `.ts` & `.tsx`
|
|
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 {
|
|
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";
|
|
@@ -184,14 +184,14 @@ function viteReact(opts = {}) {
|
|
|
184
184
|
return newBabelOptions;
|
|
185
185
|
})();
|
|
186
186
|
const plugins = [...babelOptions.plugins];
|
|
187
|
-
let reactCompilerPlugin
|
|
188
|
-
if (reactCompilerPlugin
|
|
189
|
-
plugins.splice(plugins.indexOf(reactCompilerPlugin
|
|
190
|
-
reactCompilerPlugin
|
|
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
|
|
193
|
-
plugins.splice(plugins.indexOf(reactCompilerPlugin
|
|
194
|
-
reactCompilerPlugin
|
|
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
|
|
211
|
+
retainLines: reactCompilerPlugin ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
|
|
212
212
|
parserOpts: {
|
|
213
213
|
...babelOptions.parserOpts,
|
|
214
214
|
sourceType: "module",
|
package/package.json
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-react",
|
|
3
|
-
"version": "5.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
|
-
"
|
|
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
|
-
"
|
|
21
|
-
"
|
|
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.
|
|
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-
|
|
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.
|
|
61
|
-
"react-dom": "^19.2.
|
|
62
|
-
"rolldown": "1.0.0-
|
|
63
|
-
"tsdown": "^0.
|
|
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
|
}
|