-
-
Notifications
You must be signed in to change notification settings - Fork 153
How to make a clojure library self host compatible
Yehonathan Sharvit edited this page Jun 6, 2018
·
11 revisions
In order to make a clojure library self host compatible, you need first to port it to cljc
and then make it self-host compatible.
- rename non macro files from
.clj
to.cljc
- use reader conditionals when a different code is needed for clojure and clojurescript
- move the macros code into a
.clj
or.cljc
file - Use macrovich: It simplifies a lot the write of self-host compatible macros
- install planck and lumo
- move to the main folder of your library
- Launch planck/lumo with the correct classpath:
planck -c`lein classpath`
or
lumo -c`lein classpath`
- require the namespaces of your library
- fix the bugs
- test again
Once you are done push the code to github and test online with KLIPSE.
- Open the KLIPSE REPL with
external-data-libs=[<your raw github root>]
e.g.http://app.klipse.tech/?external-libs=[https://raw.githubusercontent.com/viebel/math.combinatorics/master/src/main/clojure/]
- require the namespaces of your libray
- fix the bugs and re-push
- test again
- add the
verbose=1
url parameter to get (helpful) debug messages
First of all, take a deep breath: it's not easy to make a lib self-host compatible. But at the end of the day, you will be very happy!
In self-host, reader conditionals always branch to :cljs
- even for macro files.
Clojure
and Clojurescript
data types and protocols are very different
It's hard!