-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Woes with SSR and Promises #3853
Comments
I suppose this is related: #958 |
In svelte-loadable we worked around this problem by requiring the user to "register" loadables (dynamic imports) ahead of time. Internally, we keep a list of the registered loadables and can decide whether to do the loading, and display the "loading" slot, or to immediately use the loadable, if it has already been loaded. You can also see a version of this working in my meteor based starter. |
I do wonder if there is a way Svelte could be adjusted to render resolved promises immediately instead of waiting a minimum of one tick. It could be a nice cheap performance win. |
@CaptainN it would fix a lot of problems regarding ssr & lazy/dynamic loading |
Even with an already-resolved promise, there is no way to get its value synchronously. |
Not through the promise, but there are ways to work around that. I set up |
I'm having trouble setting up SSR in a Svelte project that utilizes dynamic imports. I'm bundling the app with Rollup, producing a single JS file with dynamic imports inlined.
Best described with code:
...rendering this on the server will yield
Similarly, getting rid of the
{#await ...}
block and just setting the route directly like so......will yield:
The above code is compiled into this:
The issue of course is the promise here.
It's pretty common to have an app that uses route based code-splitting. How does one, with Svelte, handle server-side rendering in that case? Extract routing outside of the Svelte app, and just render the specific Svelte page components directly?
Are there any good solutions to combining SSR and code-splitting and if so, should they be documented?
The text was updated successfully, but these errors were encountered: