Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: throw when refresh runtime is loaded twice (#108) (fixes #193) #194

Merged
merged 1 commit into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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