anmonteiro Code ramblings

Om Next and Bootstrapped ClojureScript

A small number of changes to Om Next makes it possible to use it from self-hosted ClojureScript environments. Read on!

Update: Starting at version 1.0.0-alpha42, Om Next now includes support for Bootstrap ClojureScript.

Something that doesn't cease to amaze me, even after more than a year now, is that ClojureScript can compile itself. The possibilities are immense, and so far we have only touched the tip of the iceberg. There are however some caveats to it, which means that not every library out there can work with Bootstrapped ClojureScript. But achieving compatibility is usually not troublesome, and there even exists a core.async fork which works in self-hosted environments.

With this in mind, I set out to discover what changes would be required for Om Next to work in bootstrapped Clojurescript environments such as Planck.

I was set for a surprise. As it turns out, only a very small number of changes are required for Om Next to work in Planck. I've prepared a simple script which you can run to try out all this goodness right now. It only requires that you have Planck 1.12 or higher installed.

Below is an example of running Om Next in bootstrapped ClojureScript. Obviously we can't use actual DOM rendering as Planck doesn't run in a browser context, but React server rendering comes to the rescue!

{% gist anmonteiro/4bf3982a0c301535b022709d58a1e94a planck-out.cljs %}

While I currently only envision myself using Om Next in self hosted environments to try out the casual snippet or clarify a user question, I suspect it will start being used in an unforeseen number of cases in the foreseeable future.

Thanks for reading!