@vitejs/plugin-react 6.2.0 → 6.3.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/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const silenceUseClientWarning = (userConfig) => ({ rollupOptions: { onwarn(warni
|
|
|
42
42
|
// src/reactCompilerPreset.ts
|
|
43
43
|
const defaultCodeFilter = /forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/;
|
|
44
44
|
const reactCompilerPreset = (options = {}) => ({
|
|
45
|
-
preset:
|
|
45
|
+
preset: [fileURLToPath(import.meta.resolve("#babelPreset")), options],
|
|
46
46
|
rolldown: {
|
|
47
47
|
filter: { code: options.compilationMode === "annotation" ? /['"]use memo['"]/ : defaultCodeFilter },
|
|
48
48
|
applyToEnvironmentHook: (env) => env.config.consumer === "client",
|
|
@@ -229,7 +229,7 @@ function createReactCompilerPlugin({ logDiagnostics, ...reactCompilerOptions },
|
|
|
229
229
|
const [filepath] = id.split("?");
|
|
230
230
|
const isJSX = filepath.endsWith("x");
|
|
231
231
|
const isClient = this.environment?.config.consumer !== "server";
|
|
232
|
-
const refreshEnabled = isClient && isFastRefreshEnabled() && (jsxRefreshFilter
|
|
232
|
+
const refreshEnabled = isClient && isFastRefreshEnabled() && (jsxRefreshFilter ? jsxRefreshFilter(id) : isJSX || code.includes(jsxImportRuntime) || code.includes(jsxImportDevRuntime));
|
|
233
233
|
const shouldCompile = isClient && (reactCompilerOptions.compilationMode === "annotation" ? /['"]use memo['"]/.test(code) : defaultCodeFilter.test(code));
|
|
234
234
|
const { transform } = compiler ?? await loadCompiler((message) => this.error(message));
|
|
235
235
|
const result = await transform(id.split("?")[0], code, {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
// src/reactCompilerBabelPreset.ts
|
|
3
|
+
function reactCompilerBabelPreset(_api, options = {}) {
|
|
4
|
+
return { plugins: [[fileURLToPath(import.meta.resolve("babel-plugin-react-compiler")), options]] };
|
|
5
|
+
}
|
|
6
|
+
export { reactCompilerBabelPreset as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-react",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "The default Vite plugin for React projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fast refresh",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
],
|
|
31
31
|
"type": "module",
|
|
32
32
|
"imports": {
|
|
33
|
-
"#optionalTypes": "./types/optionalTypes.d.ts"
|
|
33
|
+
"#optionalTypes": "./types/optionalTypes.d.ts",
|
|
34
|
+
"#babelPreset": "./dist/reactCompilerBabelPreset.js"
|
|
34
35
|
},
|
|
35
36
|
"exports": {
|
|
36
37
|
".": "./dist/index.js",
|