Building Athens Research (Clojure/JS)

Tags

  • tools

I have no idea how Clojure frontend works. This is a writeup process of me trying to figure out how to build Athens.

Tooling

Athens is a Roam-like opensource personal knowledge base written in Clojure and compiled via shadow-cljs which is like a Clojure-to-JS transpiler (?) consisting of a JAR and an npm interface. Cf. ClojureScript and initial Athens commit.

Apparently you’ll also need Leiningen which is some dependency/config/project manager for Clojure.

Leiningen manages projects for you. Lein takes care of pulling in dependencies (including Clojure itself), running the REPL, running your program and its tests, packaging your program for distribution, and other administrative tasks

Building

First install required dependencies via Node using npm install. Current Athens commit has conflicting deps and produces scary messages like:

Could not resolve dependency:
peer react@">=16.13.1" from react-kapsule@2.2.1

So hack around this by setting package.json to ">=16.9.0" and hope it doesn’t break anything.

Then use npm execute alias npx shadow-cljs (which will auto-download the shadow-cljs binary) to build the actual app. Builds are described using EDN format. E.g. npx shadow-cljs release app will transpile the Clojure code into resources/public/js/compiled/app.js as per this config.

Useful commands:

$ npx shadow-cljs help
$ npx shadow-cljs compile app
$ npx shadow-cljs start

Starting the shadow-cljs server apparently also runs some sort of build front-end on localhost:9630.

After compiling app and heading to localhost:3000, things should work.