-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Promise and lazy routes... #104
Comments
I wish I was able to do! @ItalyPaleAle I found many issues with I'll open issues as soon it works on REPL (hmmhmmhm/svelte-spa-chunk#3). From some tests that I did it showed an increase of about 10 KB using it (but testing it only with 3 routes). Not bad but I think And also the code should be on this repository, with the tests and releases aligned. Can I ask you why you "shy away" the idea of using your magnificent mental abilities to equip us, mortals, with an essential feature like this? |
See what $: if (activeRouter) {
if (!component) { // component passed as slot
hasLoaded = true;
} else if (isSvelteComponent(component)) { // component passed as Svelte component
hasLoaded = true;
} else if (isPromise(component)) { // component passed as import()
component.then(module => {
component = module.default;
hasLoaded = true;
});
} else { // component passed as () => import()
component().then(module => {
component = module.default;
hasLoaded = true;
});
}
} |
I tried some code and it works using it like this:
It loads route but I'm having issues with this:
|
I think we do not need Code splitting comes free from Rollup. We need only to handle I think you can do it in a few minutes, @ItalyPaleAle. |
First of all, I will answer the issue that occurred in my chunk module in the post you left. I am currently providing an example of Code Splitting in the form of a template based on Parcel. The last time I tried the split code in Rollup, there were a lot of problems. The last time I checked in Rollup, it looked like it was well separated, Once you download all the files, you can see that the code processing for the purpose of deciding whether or not to upload them to memory is already done by the svelte-spa-router. The code that simply uses import code in brackets is in a way not code splitting. I used svelte-loadable to implement code spliting + dynamic import If Rollup is a simple method of physical code spliting and that method is available for page-level rendering of svelte-spa-router, please share an example or PR separately. |
@hmmhmmhm thanks for your commitment. I'm not an expert here. I think your work is valuable. But can you please look at #104 (comment) which comes from
|
@frederikhors OK! I will check it within this week and if possible, I will apply it to the spa-router. I'm sorry that I can't check early because I have a bad cold. |
Thanks for the great discussion. I think y'all are right and it's time we implement this natively in the router. @hmmhmmhm let me know if you are able to work on a PR. If you can, I'd greatly appreciate it, but no pressure :) I'm scheduling this for 3.0 |
Dear @ItalyPaleAle, I figured out how to use lazy and "preloaded" routes in This is an example: https://codesandbox.io/s/svelte-spa-router-lazy-and-promises-routes-7zthn. Do you have suggestions? For example I'm already repeating the <script>
import Lazy from '../../Lazy.svelte'
</script>
<Lazy component={import('./Index.svelte')} /> and for "preloaded" routes I'm using this: import("./routes/preloaded/Index.svelte") which maybe is not very elegant. What do you think? Thanks again for your work! This is the best router today and I say it because I tried them all! |
There's currently work being done in #73 to support dynamically-imported routes. Once that's implemented, it will be possible to do a lazy loading too, by invoking I'll write some docs on how to do this |
Looking at
yrv
router (a good router!) we can see two ways of importing routes:With https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/Advanced%20Usage.md#async-route-loading we have just the lazy one. Am I correct?
I think it would be useful (and amazing) to have both in
svelte-spa-router
(three-shaked if we do not use them).The promise way I think is amazing because I can have a lot of routes and maybe I just need to load immediately just the one I need and after that in background start downloading others.
What do you think about?
The text was updated successfully, but these errors were encountered: