Skip to content

Commit 13cd4a4

Browse files
committed
fix: throw when refresh runtime is loaded twice (fix #101)
1 parent ca785b6 commit 13cd4a4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/plugin-react/src/refreshUtils.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/* eslint-disable no-undef */
2+
if (typeof window !== 'undefined') {
3+
if (window.__vite_plugin_react_runtime_loaded__) {
4+
throw new Error(
5+
'React refresh runtime was loaded twice. Maybe you forgot the base path?',
6+
)
7+
}
8+
window.__vite_plugin_react_runtime_loaded__ = true
9+
}
10+
111
function debounce(fn, delay) {
212
let handle
313
return () => {
@@ -6,7 +16,6 @@ function debounce(fn, delay) {
616
}
717
}
818

9-
/* eslint-disable no-undef */
1019
const enqueueUpdate = debounce(exports.performReactRefresh, 16)
1120

1221
// Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141

0 commit comments

Comments
 (0)