这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@voughtdq
Copy link
Contributor

To facilitate the creation of alternative SSR behaviours, the the implementation-specific code is relocated into its own module. This is backwards compatible, but will emit a deprecation warning. There are also some basic tests to verify that we default to NodeJS for backwards compatibility.

I've also started working on a subproject to do end-to-end testing, but would like to iron out any concerns here before moving on to that.

Partially addresses what was discussed in #81

To facilitate the creation of alternative SSR behaviours, the
the implementation-specific code is relocated into its own module.
This is backwards compatible, but will emit a deprecation warning.
There are also some basic tests to verify that we default to NodeJS for
backwards compatibility.
try do
NodeJS.call!({"server", "render"}, [name, props, slots])
catch
:exit, {:noproc, _} -> raise LiveSvelte.SSR.NodeNotConfigured
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change too much, but it might make sense to have a more general-purpose SSRNotConfigured exception.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add this, makes sense!

Copy link
Contributor Author

@voughtdq voughtdq Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using config here reveals the limitation that the Elixir documentation for library developers describes. What if a developer wants to use more than one SSR implementation? Or a situation where a developer wants to pull in dependencies that have different SSR implementations.

On one hand, using config is easy and it addresses the most common use cases. On the other hand, we could use macros to provide this configuration and the developer could configure the SSR module they want to use as part of their code. Macros are of course seen as unwieldy and magical, so that's the trade off.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one SSR implementation is good enough. It can always be supported later if there's a need for it

@woutdp
Copy link
Owner

woutdp commented Sep 14, 2023

Thank you for the great work!

What still is missing is automatic setup for when you run mix live_svelte.setup and the example_project should still be adjusted I believe. Feel free to do these changes too, if not I'll tackle them myself :)

@voughtdq
Copy link
Contributor Author

Sounds good, I'll work on that today.

@voughtdq
Copy link
Contributor Author

@woutdp can you look over the changes? I'm getting close to finishing up a first attempt at trying creating an alternative Node JS implementation and these changes would be useful for testing.

@woutdp woutdp merged commit 1119f41 into woutdp:master Sep 25, 2023
@woutdp
Copy link
Owner

woutdp commented Sep 25, 2023

@voughtdq done, thank you for the great work!

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

Successfully merging this pull request may close these issues.

2 participants