-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Weird compiler error with build target esnext and styled components #5052
Comments
This only seems to happen with The error happens when building the ssr bundle. The client is built and contains a css file for the component, albeit with that strange name, that originates from vite-plugin-svelte's virtual css id for the component. It looks like a failed tree shaking attempt. |
sounds related: vitejs/vite#8330 |
This fixes our issue in Astro: vitejs/vite@85299c2 Might try patching that locally and see if it fixes for you. PR: vitejs/vite#8345 |
Worth a try, thanks. The fix for vite is looking to be correct. However I'm not sure we actually want that behavior. Instead it should keep Foo anyways because it is determined at runtime whether to use it or not. Not sure what made it come to the conclusion that Foo can be dropped from code like this <script>
import Foo from './Foo.svelte';
let showFoo = false; // or Date.now() < 0 or Math.random() > 1
</script>
{#if showFoo}
<Foo />
{/if} |
No longer reproducible with the latest version of Kit/Vite |
Describe the bug
We encountered a very weird bug with the SvelteKit compiler. In a very specific constellation, the build task fails with an error (see Logs section below).
I created a GitHub Repository with the exact constellation to reproduce the error https://github.com/vekunz/sveltekit-crazy-compiler-error.
Reproduction
To reproduce the error, you need four things to exist in your SvelteKit application.
svelte.config.js
set the keykit.vite.build.target
toesnext
.SomeComponent.svelte
)__layout.svelte
and anysome-route.svelte
, which both use the component from step 2.__layout.svelte
or thesome-route.svelte
(or in both) inside an{#if ...}
statementLogs
System Info
Severity
serious, but I can work around it
Additional Information
For now, we can work around it, but it is just a matter of time when this blocks all usage of SvelteKit for us.
The text was updated successfully, but these errors were encountered: