From 26b399191df99f15bcf98b9b63aab133ab60a7e5 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 18 Jul 2025 14:06:23 +0900 Subject: [PATCH 1/2] fix!: remove `resolve.dedupe` --- packages/plugin-react/CHANGELOG.md | 6 ++++++ packages/plugin-react/src/index.ts | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index 4c764e635..e466c3c3b 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +### `react` and `react-dom` is no longer added to [`resolve.dedupe`](https://vite.dev/config/#resolve-dedupe) automatically + +Adding values to `resolve.dedupe` will force Vite to resolve them in a different way than Node.js does, which is confusing and may not be expected. This plugin no longer adds `react` and `react-dom` to `resolve.dedupe` automatically. + +If you encounter an error after upgrading, check the `dependencies` / `devDependencies` in `package.json` and the package manager's configuration. If you want the previous behavior, you can add `react` and `react-dom` to `resolve.dedupe` manually. + ## 4.7.0 (2025-07-18) ### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518)) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index f8dd135a4..9affdb547 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -364,9 +364,6 @@ export default function viteReact(opts: Options = {}): Plugin[] { optimizeDeps: { include: dependencies, }, - resolve: { - dedupe: ['react', 'react-dom'], - }, }), resolveId: { filter: { id: exactRegex(runtimePublicPath) }, From 782404fb0f6888c9047de08dd67a5b82f43d9756 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 18 Jul 2025 14:10:00 +0900 Subject: [PATCH 2/2] chore: update changelog --- packages/plugin-react/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index e466c3c3b..96278ac2c 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -4,9 +4,9 @@ ### `react` and `react-dom` is no longer added to [`resolve.dedupe`](https://vite.dev/config/#resolve-dedupe) automatically -Adding values to `resolve.dedupe` will force Vite to resolve them in a different way than Node.js does, which is confusing and may not be expected. This plugin no longer adds `react` and `react-dom` to `resolve.dedupe` automatically. +Adding values to `resolve.dedupe` forces Vite to resolve them differently from how Node.js does, which can be confusing and may not be expected. This plugin no longer adds `react` and `react-dom` to `resolve.dedupe` automatically. -If you encounter an error after upgrading, check the `dependencies` / `devDependencies` in `package.json` and the package manager's configuration. If you want the previous behavior, you can add `react` and `react-dom` to `resolve.dedupe` manually. +If you encounter errors after upgrading, check your package.json for version mismatches in `dependencies` or `devDependencies`, as well as your package manager’s configuration. If you prefer the previous behavior, you can manually add `react` and `react-dom` to `resolve.dedupe`. ## 4.7.0 (2025-07-18)