woutdp / live_svelte

Svelte inside Phoenix LiveView with seamless end-to-end reactivity
https://hexdocs.pm/live_svelte
MIT License
1.01k stars 37 forks source link

Code Splitting #88

Closed absowoot closed 5 months ago

absowoot commented 8 months ago

If you import a heavy dependency, like Maplibre, it increases the bundle size drastically. I was able to figure this out for standard Phoenix applications with help from this thread but attempting this with live_svelte results in the following error: Cannot use import statement outside a module

Is code splitting possible with live_svelte and/or loading component dependencies on demand?

Seemingly related to #36

woutdp commented 8 months ago

Take a look at https://github.com/woutdp/live_svelte/discussions/57#discussioncomment-6289249 maybe. It's using Vite.

absowoot commented 8 months ago

Switching to Vite seems counter-intuitive. I really enjoy the ease of using (live_)svelte and especially the ability to include all component-related code in one file but this puts a pause on my switch to live_svelte.

woutdp commented 8 months ago

I think with Vite you'd still be able to use live_svelte like regular as before, except that modules will be loaded dynamically. I've never tested it out though so I might be wrong here...

woutdp commented 5 months ago

Closing for now