Automatic code splitting causing route files to import from my entry point (circular)
Hey, everyone! I'm running into a strange issue with automatic code splitting. Essentially, I have a SPA which has an entrypoint of lead-journey.js. My vite config is adding these imports to my index.html:
When loading a page of the app, I get an invariant failed error in the console (I have minify turned off so that the symbols are easier to read):
That confused me for a while, but I think it's happening because the lead-journey.js file is being loaded twice (lead-journey.js is my entrypoint script that's supposed to kick off everything else). When I look at the network tab and find that the lead-journey.js script is being loaded twice, the first is from the script tag shown above and the second is from the file
Does anyone know what's going on and how I can prevent this behavior? I'd like to have the code splitting turned on, because my bundle size is huge when everything is combined into lead-journey.js.
Thanks!
When loading a page of the app, I get an invariant failed error in the console (I have minify turned off so that the symbols are easier to read):
That confused me for a while, but I think it's happening because the lead-journey.js file is being loaded twice (lead-journey.js is my entrypoint script that's supposed to kick off everything else). When I look at the network tab and find that the lead-journey.js script is being loaded twice, the first is from the script tag shown above and the second is from the file
route-DGWPBI4S.js:3, which is one of the files generated by the automatic code splitting. If I look into the code of that file, I see this:Does anyone know what's going on and how I can prevent this behavior? I'd like to have the code splitting turned on, because my bundle size is huge when everything is combined into lead-journey.js.
Thanks!