Thanks to Microsoft’s diligent open-source work, we can now build an app on macOS in a modern Lisp, with a connected REPL and everything. For those of us who remember the 90s, this is truly the dankest timeline.
The only dependency Krell requires above vanilla React Native is react-native-tcp-socket, which as of 3.6.0 compiles just fine on macOS. Building a macOS app, then, just requires mashing together Microsoft’s macOS/RN instructions with Krell’s.
Start by creating a new React Native for Mac app:
Note that you need to specify version 0.61 of React Native, as that’s where
Microsoft’s fork has caught up to so far. Next, follow the Krell
Reagent tutorial to
set up your ClojureScript project. Add a
(You should probably grab the latest SHA for
io.vouch/krell, but this one at
least has the correct deps).
Add a ClojureScript source file at
clj -m cljs.main --install-deps to install Krell’s NPM deps, then install
the native dependencies:
You’re now ready to go.
clj -m krell.main -co build.edn -c -r will build your
ClojureScript source and start the REPL.
npx react-native run-macos will build
your project, launch it, and connect. From there you can interact from the REPL
or change the source to see it hot-reload.
Can this work on Windows?
Microsoft’s React Native fork that supports Windows is actually ahead of its
macOS fork. The missing piece is the
react-native-tcp-socket library. Once
native bindings for Windows are built for that, these instructions should
work on Windows as well.