From 93c2a832dac061d80a27dbbad31df1869249d031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sat, 8 Jul 2023 18:45:00 +0200 Subject: [PATCH] revert #108: throw when refresh runtime is loaded twice --- packages/plugin-react/CHANGELOG.md | 2 ++ packages/plugin-react/src/refreshUtils.js | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index 903c3f1c..9ed8ead2 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Revert [#108](https://github.com/vitejs/vite-plugin-react/pull/108): Remove throw when refresh runtime is loaded twice to enable usage in micro frontend apps. This was added to help fix setup usage, and this is not worth an annoying warning for others or a config parameter. + ## 4.0.2 (2023-07-06) - Fix fast-refresh for files that are transformed into jsx ([#188](https://github.com/vitejs/vite-plugin-react/pull/188)) diff --git a/packages/plugin-react/src/refreshUtils.js b/packages/plugin-react/src/refreshUtils.js index 9f657f30..98b2f3af 100644 --- a/packages/plugin-react/src/refreshUtils.js +++ b/packages/plugin-react/src/refreshUtils.js @@ -1,13 +1,3 @@ -/* eslint-disable no-undef */ -if (typeof window !== 'undefined') { - if (window.__vite_plugin_react_runtime_loaded__) { - throw new Error( - 'React refresh runtime was loaded twice. Maybe you forgot the base path?', - ) - } - window.__vite_plugin_react_runtime_loaded__ = true -} - function debounce(fn, delay) { let handle return () => { @@ -16,6 +6,7 @@ function debounce(fn, delay) { } } +/* eslint-disable no-undef */ const enqueueUpdate = debounce(exports.performReactRefresh, 16) // Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141