What is happening is __vite_plugin_react_preamble_installed__ is not getting set before my javascript libraries load, and it is throwing the error.
If we simply reorder the injected scripts so that the Vite React preamble code is loaded before any user javascript libraries, the problem seems to be fixed
Before submitting the issue, please make sure you do the following
Describe the bug
When trying to enable react fast refresh script, I get following error in browser console:
Reproduction
Using following vite config:
System Info
Output of
npx envinfo --system --npmPackages @aem-vite/aem-vite --binaries --browsers
:package.json versions:
Used package manager:
npm
Logs
N/A
Possible solution
in https://github.com/aem-vite/vite-aem-plugin/blob/main/src/helpers.ts#L25, the function
getViteScripts
appends the react refresh script last.So in my browser HTML I see the following:
What is happening is
__vite_plugin_react_preamble_installed__
is not getting set before my javascript libraries load, and it is throwing the error.If we simply reorder the injected scripts so that the Vite React preamble code is loaded before any user javascript libraries, the problem seems to be fixed
Before submitting the issue, please make sure you do the following
@aem-vite/aem-vite
and not a Rollup/Vite issue.