-
We have a huge However, we are about to extract components out of our
A Svelte 4 component would of course when imported to a Svelte 4 app (doh!), but would a Svelte 5 component work? Are there gotchas/footguns that we should be wary of? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You cannot directly import components using Svelte 5 syntax in a Svelte 4 project. It is recommended for component libraries to distribute the (pre-processed) source of components, so the Svelte 4 compiler would not understand that. Even if the components are compiled down to JS that does not quite work because the mounting mechanism is different. It might be possible if you add exports that wrap all the components in |
Beta Was this translation helpful? Give feedback.
-
You can only use components authored with runes in applications compiled with the svelte5 compiler. Now the svelte5 compiler understands svelte4 syntax, so you can migrate your huge kit app to use the svelte5 compiler by updating to that version even without updating all of your code. (some small adjustments might have to be made but they should be reasonable). Once the app is compiled with svelte5, you can use svelte5 syntax component libraries too even if your application code is still using svelte4 syntax. |
Beta Was this translation helpful? Give feedback.
You can only use components authored with runes in applications compiled with the svelte5 compiler.
So if you want to make a component library that is compatible to svelte4 compiler, you have to stick with svelte4 syntax.
Now the svelte5 compiler understands svelte4 syntax, so you can migrate your huge kit app to use the svelte5 compiler by updating to that version even without updating all of your code. (some small adjustments might have to be made but they should be reasonable).
Once the app is compiled with svelte5, you can use svelte5 syntax component libraries too even if your application code is still using svelte4 syntax.