Description
Description
As a developer using vite in an micro front end environment we do need to have multiple loads of the @react-refresh
when we are in dev mode with multiple micro apps.
In version 4 was added a throw error
when one has multiple loads of the react-refresh which we do, because they are located on different urls, while window object is shared with all micro-apps.
And window.vite_plugin_react_runtime_loaded is shared as well which will cause a throw, and any micro app after first loaded micro app will die.

Suggested solution
Could we add an option which can disable react-refresh throw React refresh runtime was loaded twice...
?
/* eslint-disable no-undef */
if (typeof window !== 'undefined') {
**if(!disableThrowMultiLoading){**
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
}
Alternative
Alternative can be not to throw but to console.warn this.
/* eslint-disable no-undef */
if (typeof window !== 'undefined') {
if (window.__vite_plugin_react_runtime_loaded__) {
--// throw new Error(
++ console.warn(
'React refresh runtime was loaded twice. Maybe you forgot the base path?',
)
}
window.__vite_plugin_react_runtime_loaded__ = true
}
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.