Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support loading css first #1032

Open
dominikg opened this issue Nov 25, 2024 · 4 comments
Open

support loading css first #1032

dominikg opened this issue Nov 25, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@dominikg
Copy link
Member

Describe the problem

Currently css is cached and returned as a virtual module when .svelte files are imported as js module.
But with vite ?direct or ?inline query urls, it is possible that the first request is not for the js module but the css.

Describe the proposed solution

In case the cache is empty when css is requested, compile.

Alternatives considered

keep current behavior, styles might not be needed before the js module

Importance

nice to have

@dominikg dominikg added enhancement New feature or request triage Awaiting triage by a project member labels Nov 25, 2024
@dominikg
Copy link
Member Author

see #341 #1024

@dominikg dominikg removed the triage Awaiting triage by a project member label Nov 26, 2024
@SystemParadox
Copy link

SystemParadox commented Mar 12, 2025

We're seeing a lot of issues with this, where the .svelte file gets loaded from browser cache but the CSS doesn't, so you get a garbage <style> injected with the full file content instead of the CSS.

I'm still trying to work out if our particular issue is because something is being cached when it shouldn't be, but the current behaviour is really confusing - at the very least if the CSS isn't available it should 404 or something and show a clear error somewhere instead of returning garbage.

@dominikg
Copy link
Member Author

.svelte files never end up in the browser cache. do you mean js modules compiled from .svelte files? please file a separate issue with a reproduction for this.

@SystemParadox
Copy link

.svelte files never end up in the browser cache. do you mean js modules compiled from .svelte files? please file a separate issue with a reproduction for this.

Yes. I've opened vitejs/vite#19632 because I think it's a general vite issue. But it would have helped a lot with debugging this if vite-plugin-svelte had given a clear error instead of silently returning garbage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants