Open dev-guy opened 9 months ago
This seems like the way to go, there's a couple of issues that could be possibly closed by this. Anyone feel free to pick it up or create a separate package like https://github.com/revelrylabs/elixir-nodejs
There are a few ideas I have for fixing SSR, but all would require experimentation.
One idea is creating a general purpose cnode addon for Node.js. That way, Node.js does work and replies to the erlang messages it receives with the rendered components. This would also offload some of the cost of converting JavaScript types to erlang terms since the communication and conversion is done natively.
The other idea is to use something like zmq and create a communication protocol with Node.js.
Even going with Bun and implementing a cnode there might speed things up.
Of course doing this communication over TCP could actually end up slowing things down.
There are also other things to try with the existing Port - like avoiding converting data received from the Port to a binary and just using the charlist it passes instead and not trying to encode it using Jason.
Opinions on making an SSR behaviour and allowing configuration to define what SSR module gets used? This would make experimentation and testing with various implementations easier.
Great idea to create an SSR behaviour. I can imagine some people would still want to use Node
as they might already be using that dependency in their project, and are reluctant to add Bun as an extra dependency. So would be nice to be able to plug in whichever SSR backend you want to use.
As for the implementation I'm not familiar with cnode
, no opinion on it.
I'm mainly looking at speed and reliability. Whichever is fastest and renders without issues would be ideal.
Sounds good. I will try to put something together to get an SSR behaviour.
https://github.com/crbelaus/elixir_bun
It seems there is already a Bun package for Elixir. I'll leave it here for reference
Have you considered Deno and specifically deno_ex instead of Node or Bun?
Svelte seems to be available too https://deno.land/x/svelte@v3.44.2
Have you considered Deno and specifically deno_ex instead of Node or Bun?
Svelte seems to be available too https://deno.land/x/svelte@v3.44.2
Yes although I'm not sure if deno would fix the performance issues. In any case, I want the SSR 'runtime' to be configurable, so you'd have the option to choose between Node, Bun or Deno (and maybe others later).
Bun 1.0 was released last week. There are many issues with SSR - it's slow and at times erratic. Perhaps Bun is the answer.
https://bun.sh/guides/ecosystem/sveltekit