@vitejs/plugin-react
Advanced tools
+20
-11
@@ -104,2 +104,3 @@ import { dirname, join } from "node:path"; | ||
| const tsRE = /\.tsx?$/; | ||
| const compilerAnnotationRE = /['"]use memo['"]/; | ||
| function viteReact(opts = {}) { | ||
@@ -137,3 +138,3 @@ const include = opts.include ?? defaultIncludeRE; | ||
| runtime: "automatic", | ||
| importSource: jsxImportSource, | ||
| importSource: opts.jsxImportSource, | ||
| refresh: command === "serve" | ||
@@ -144,3 +145,3 @@ }, | ||
| }, | ||
| optimizeDeps: { rollupOptions: { jsx: { mode: "automatic" } } } | ||
| optimizeDeps: { rollupOptions: { transform: { jsx: { runtime: "automatic" } } } } | ||
| }; | ||
@@ -151,3 +152,3 @@ if (opts.jsxRuntime === "classic") return { esbuild: { jsx: "transform" } }; | ||
| jsx: "automatic", | ||
| jsxImportSource | ||
| jsxImportSource: opts.jsxImportSource | ||
| }, | ||
@@ -199,5 +200,14 @@ optimizeDeps: { esbuildOptions: { jsx: "automatic" } } | ||
| const plugins = [...babelOptions.plugins]; | ||
| let reactCompilerPlugin$1 = getReactCompilerPlugin(plugins); | ||
| if (reactCompilerPlugin$1 && ssr) { | ||
| plugins.splice(plugins.indexOf(reactCompilerPlugin$1), 1); | ||
| reactCompilerPlugin$1 = void 0; | ||
| } | ||
| if (Array.isArray(reactCompilerPlugin$1) && reactCompilerPlugin$1[1]?.compilationMode === "annotation" && !compilerAnnotationRE.test(code)) { | ||
| plugins.splice(plugins.indexOf(reactCompilerPlugin$1), 1); | ||
| reactCompilerPlugin$1 = void 0; | ||
| } | ||
| const isJSX = filepath.endsWith("x"); | ||
| const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime))); | ||
| if (useFastRefresh && !isRolldownVite) plugins.push([await loadPlugin("react-refresh/babel"), { skipEnvCheck: true }]); | ||
| const useFastRefresh = !isRolldownVite && !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime))); | ||
| if (useFastRefresh) plugins.push([await loadPlugin("react-refresh/babel"), { skipEnvCheck: true }]); | ||
| if (opts.jsxRuntime === "classic" && isJSX) { | ||
@@ -216,3 +226,3 @@ if (!isProduction) plugins.push(await loadPlugin("@babel/plugin-transform-react-jsx-self"), await loadPlugin("@babel/plugin-transform-react-jsx-source")); | ||
| sourceFileName: filepath, | ||
| retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic", | ||
| retainLines: reactCompilerPlugin$1 ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic", | ||
| parserOpts: { | ||
@@ -245,3 +255,3 @@ ...babelOptions.parserOpts, | ||
| apply: "serve", | ||
| transform: isRolldownVite ? { | ||
| transform: { | ||
| filter: { id: { | ||
@@ -257,3 +267,3 @@ include: makeIdFiltersToMatchWithQuery(include), | ||
| if (!useFastRefresh) return; | ||
| const { code: newCode } = addRefreshWrapper(code, avoidSourceMapOption, "@vitejs/plugin-react", id); | ||
| const { code: newCode } = addRefreshWrapper(code, avoidSourceMapOption, "@vitejs/plugin-react", id, opts.reactRefreshHost); | ||
| return { | ||
@@ -264,3 +274,3 @@ code: newCode, | ||
| } | ||
| } : void 0 | ||
| } | ||
| }; | ||
@@ -315,4 +325,3 @@ const viteConfigPost = { | ||
| viteBabel, | ||
| viteRefreshWrapper, | ||
| viteConfigPost, | ||
| ...isRolldownVite ? [viteRefreshWrapper, viteConfigPost] : [], | ||
| viteReactRefresh | ||
@@ -319,0 +328,0 @@ ]; |
+5
-5
| { | ||
| "name": "@vitejs/plugin-react", | ||
| "version": "5.0.0", | ||
| "version": "5.0.1", | ||
| "license": "MIT", | ||
@@ -43,6 +43,6 @@ "author": "Evan You", | ||
| "dependencies": { | ||
| "@babel/core": "^7.28.0", | ||
| "@babel/core": "^7.28.3", | ||
| "@babel/plugin-transform-react-jsx-self": "^7.27.1", | ||
| "@babel/plugin-transform-react-jsx-source": "^7.27.1", | ||
| "@rolldown/pluginutils": "1.0.0-beta.30", | ||
| "@rolldown/pluginutils": "1.0.0-beta.32", | ||
| "@types/babel__core": "^7.20.5", | ||
@@ -59,6 +59,6 @@ "react-refresh": "^0.17.0" | ||
| "react-dom": "^19.1.1", | ||
| "rolldown": "1.0.0-beta.30", | ||
| "tsdown": "^0.13.2", | ||
| "rolldown": "1.0.0-beta.32", | ||
| "tsdown": "^0.14.1", | ||
| "vitest": "^3.2.4" | ||
| } | ||
| } |
+1
-1
@@ -41,3 +41,3 @@ # @vitejs/plugin-react [](https://npmjs.com/package/@vitejs/plugin-react) | ||
| Control where the JSX factory is imported from. Default to `'react'` | ||
| Control where the JSX factory is imported from. By default, this is inferred from `jsxImportSource` from corresponding a tsconfig file for a transformed file. | ||
@@ -44,0 +44,0 @@ ```js |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
44360
1.49%1028
0.88%3
50%+ Added
- Removed
Updated