Non-modern build should also ("pre")load CSS
See original GitHub issueDescription
While I’m doing my efforts in sveltejs/kit#6265 to add legacy support to SvelteKit on the Vite way, I had noticed that when navigating from one page to the other, the internal function __vitePreload
is called, which is defined in the plugin importAnalysisBuild
.
As far as I understand, the purpose of this function is to preload JS modules and also to (pre?)load CSS files.
On legacy output chunks, it shuts down the preloading ability.
I understand that there is no need to preload JS modules on non-modern(i.e. non ESModule compatible) browsers, but for the correct way of loading CSS, the CSS files should(?) be loaded in __vitePreload
.
According to my local tests, if the CSS are getting preloaded on legacy builds, everything works great in my legacy work on SvelteKit.
Suggested solution
Change the code of the plugin importAnalysisBuild
to (pre?)load CSS anyway, and when the browser is also modern, import also the preloaded JS files.
Alternative
You tell me?
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.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (10 by maintainers)
It’s described here. https://github.com/vitejs/vite/issues/2062#issuecomment-782385406
Hello! Are you talking about the SvelteKit legacy PR I made? If so, you better comment this issue on the PR I sent on SvelteKit, not here.(was it a mistake?)
Anyway, for your case, can you:
npm run build && npm run preview
, and share the result? Also, can you please publish a bigger chunk of the console error? It’s seems that a detailed error message appears earlier.Please comment to me to this on the PR in SvelteKit, for a better discussion.