enhance-dev / enhance-ssr-wasm

Enhance SSR compiled for WASM
Apache License 2.0
70 stars 2 forks source link

Maybe better to call Node.js/Bun/Deno instead of QuickJS? #6

Open trusktr opened 6 months ago

trusktr commented 6 months ago

I'm wondering if it is worth using Extism (which uses QuickJS), as V8 in the benchmarks is faster. Maybe it is better to just call Node/Deno/Bun from any language, for the SSR purpose? What are your thoughts?

mariohamann commented 6 months ago

From my experience it's definitely worth the effort. I experimented with this a lot and you more or less have several options:

  1. run node/bun/deno via shell command or similar → needs to start the runtime (might be the fastest with bun) + you might get limits regarding max character amount
  2. spin up a local Node server via Fastify/Express/Whatever and communicate with it via POST → super fast, but you need to run and maintain the Node server and questions arise where to integrate it in a project (Monorepo?), have versioning in mind etc.
  3. spin up a AWS Lambda or similar → requests may take time + costs could become uncalculatable

I'm currently integrating it in a Laravel/PHP project and it feels like something IN the project, just a nice, predicatable package. There are definitely caveats and I had to think about caching "enhancements" etc. – but having a sharable, versionable bundle which works exactly the same in every project and doesn't depend on a Node runtime/server/microservice is marvelous.

I'm currently writing up my experience in my private project and will add the link as soon as it's published. :)

ryanbethel commented 6 months ago

I'm wondering if it is worth using Extism (which uses QuickJS), as V8 in the benchmarks is faster. Maybe it is better to just call Node/Deno/Bun from any language, for the SSR purpose? What are your thoughts?

That could be an option for some use cases, and if it works for you definitely try it. But calling out to a node process from Ruby for instance is something many users have told us they don't want to do. We are exploring lots of options. Even including rewriting the core SSR logic in the target language if there is enough demand. For instance, we have discussed rewriting Enhance SSR directly in PHP to make it easier to support Wordpress Plugins etc.