-
-
Notifications
You must be signed in to change notification settings - Fork 149
How to make a clojure library self host compatible
Yehonathan Sharvit edited this page Oct 27, 2016
·
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 files from
.cljto.cljc - use
#?(:cljs ... :clj)when a different code is needed for clojure and clojurescript - move the macros into a
.cljfile
- install planck
- move to the main folder of your library
- Launch planck with the correct classpath:
planck -c`lein classpath`- require the namespaces of your libray
- 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
In self-host, reader conditionals always branch to :cljs.
Clojure and Clojurescript data types and protocols are very different
Macro code must be put in a separate file - .clj or .cljc
It's hard!