Skip to content

Commit

Permalink
revert: throw when refresh runtime is loaded twice (vitejs#108) (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Jul 8, 2023
1 parent 7967375 commit 7270aff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/plugin-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 1 addition & 10 deletions packages/plugin-react/src/refreshUtils.js
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand All @@ -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
Expand Down

0 comments on commit 7270aff

Please sign in to comment.