DenoRider - An embedded JavaScript runtime in Elixir

Hi all!

I’ve put together DenoRider, a JavaScript runtime embedded in Elixir via Rustler and the deno_runtime crate.

My use case is server side rendering of a ClojureScript app. Please let me know if you use it, because it would be interesting to hear about your use case!

Example

iex> DenoRider.eval("1 + 2")
{:ok, 3}
iex> DenoRider.eval("globalThis.foo = 'bar'")
{:ok, "bar"}
iex> DenoRider.eval("globalThis.foo")
{:ok, "bar"}

Links

27 Likes

If I use it to implement React SSR (Server-Side Rendering), will there be any problem?

1 Like

No, that’s basically what I use it for.

1 Like

Do you have a example of how to achieve that? I would like to know if it’s possible to use DenoRider with a JS library such as CortexJS.

Thank you for doing this! I wanted to create a Rustler NIF around deno_runtime as well for https://github.com/akoutmos/deno_ex....but now it appears I won’t have to do that :smiley:. Thanks for checking that off my todo list!

4 Likes

this is very nice, I’ll be playing with it. This can be a basis for LiveView/React Server Components-like hybrid solution!

2 Likes

my implementation’s a bit hacky, but i made a custom SSR renderer for live_svelte with it:

4 Likes

I think CortexJS would work just fine. There’s no support for npm integration yet, though, so you need a build step to convert CortexJS to something consumable by the runtime. I suggest you take a look at what @rekkice does in his repo. :slightly_smiling_face:

2 Likes

Awesome! Thanks for sharing!

2 Likes

It worked great! We are compiling our TS file using the bun lib and then passing the resulting JS file to the DenoRider supervisor. Thanks for your effort in building it!

Do you have a roadmap with the changes/features you still want to implement or may we consider this library production-ready/stable?

1 Like

Cool! Glad to hear it’s working for you.

There’s currently no roadmap, but that’s mostly because it has everything I need for now. If you have feature requests, just put up an issue on GitHub. :slightly_smiling_face:

2 Likes

Is there support for callbacks? For example, can I invoke Elixir code to handle an event that occurs in JavaScript?

No, not yet. But I think we could add support for something like that. Can you please post an issue on GitHub and describe your use case?

1 Like

It’s done!

2 Likes