Backlit replaces all of that with two lines:
composer require bennypowers/backlit
drush en backlit
Composer downloads a pre-compiled Go binary for your platform. The binary
embeds a WASM module (QuickJS + @lit-labs/ssr, compiled via Javy). Drupal
pipes page HTML to the binary's stdin; rendered Declarative Shadow DOM HTML
comes back on stdout. The WASM instance stays warm across requests: ~350ms
cold start once per PHP-FPM worker, ~0.32ms per render after that.The funny part: I didn't build this for Drupal. I built lit-ssr-wasm to add live component previews to `cem serve` -- a dev server for custom elements manifest tooling (https://github.com/bennypowers/cem). Once the WASM module existed, the Drupal integration was an afternoon's work.
WASM is to backend runtimes what web components are to the browser: write it once, run it anywhere.