Skip to content
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

Dependency tag #5351

Closed
joas8211 opened this issue Sep 4, 2020 · 1 comment
Closed

Dependency tag #5351

joas8211 opened this issue Sep 4, 2020 · 1 comment

Comments

@joas8211
Copy link

joas8211 commented Sep 4, 2020

I've had problems with loading components asyncronously using dynamic import and SSR on JAM-stack site. Consider a situation where locally stored JSON data dictates what component to load at build-time.

The workaround I've been using thus-far is loading all the components on build-time on module context and only needed components on client-side using render-blocking if-block. But that is ugly and might cause a race condition (although only on rare cases) since the component loading on build-time isn't awaited.

What I would like to have is way to block build-time rendering (SSR) for the time of loading dynamically imported components.

I tried to implement some kind of beforeMount lifetime hook, but it doesn't seem possible with the compiled code and template being tied together. Then I tried implementing top-level await for the script block but Acorn JavaScript parser started complaining just by thought of that.

Potential feature that could solve it could be svelte:dependency tag. It could function as an await after script execution and before template rendering.

<svelte:dependency await={promise} />
@Conduitry
Copy link
Member

This is essentially a duplicate of #958. If you have a more concrete proposal, please open an RFC at https://github.com/sveltejs/rfcs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants