-
Notifications
You must be signed in to change notification settings - Fork 13
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
SSR support #13
Comments
Thank you for this detailed analysis! I haven't used Svelte with SSR myself yet but it's definitely a feature I would like to have in the build plugin. However, exporting both builds ( <!-- Component.html -->
<div>I'm a component!</div> <!-- App.html -->
<Component />
<script>
// Which of the two `import`s should be used? It depends on where
// `App.html` is imported (client or server).
import Component from "./Component.html";
import { ssr as Component } from "./Component.html";
export default {
components: {
Component
}
};
</script> I'd also like to avoid adding the Maybe we can use the same approach as Meteor's What do you think? 🙂 |
+1 on avoiding useless code on the client, I have not thought about that part.
I did not know that this is possible with a build plugin, this would definitely be the best approach! |
Great, thanks! I will try to get a testable version ready sometime this week. |
Released in version 1.64.1_1! 🙂 |
Do you think there is any chance we can get SSR support?
I was researching this topic a bit and it seems that svelte takes a rather special approach here:
https://svelte.technology/guide#server-side-rendering
This doesn't seem to work with Meteor because you cannot overload require at runtime (or at least I was not able to get it working).
Now I understand that the build plugin is providing the compile functionality for all imports (i.e. client and server) and we don't want to overcomplicate how everything works for regular client side imports. Neither can we create a new build plugin because it would process the same extensions and files. However I was wondering if there would be a way to export the {code} generated by the svelte compiler when using generate: 'ssr' along with the default export?
That way you could still do
import Example from '/imports/Example.html'
on the client and on the server for ssr you could useimport {ssr} from '/imports/Example.html'
. Another Option could be to extend the svelte class generated by the compiler and add the static.render(data)
method from the generate: 'ssr' compile step.Happy to hear your thoughts on this!
The text was updated successfully, but these errors were encountered: