Creating & using libraries in both Clojure and ClojureScript
There are some ClojureScript differences from Clojure.
Dependecies from "project.clj" can be applicable / visible / usable by ClojureScript, for example, take a look at "jayq". You would include it in "project.clj":
(defproject xyz/xyz "0.1.0-SNAPSHOT"
:dependencies [[clj-time "0.4.3"]
[jayq "2.2.0"]
....
And then use it in the ClojureScript file:
(ns xyz.some.cljs
(:require ...
...
[clojure.browser.repl :as repl]
[jayq.core :as jq])
While "jayq" is not a "Clojure" library in the "backend" sense since it just wraps JavaScript, it is an example of using a "project.clj" dependency on the ClojureScript side.
In addition most of the core and several non core libraries are already ported to the ClojureScript side:
- clojure.set
- clojure.string
- clojure.walk
- clojure.zip
- clojure.core.reducers
- fold is currently an alias for reduce
- core.match
- core.logic (in works)
Other Clojure libraries will have to conform to the ClojureScript subset in order to work in ClojureScript.
It is worthwhile to clone ClojureScript repo and get a sense of what it supported (plus add your own features if you feel adventurous :)
ClojureScript dependencies are usually "front end" based (included the ones ported from backend). In other words, the end goal is to be compiled by V8 and run as JavaScript, hence anything that can be compiled by the ClojureScript compiler (repo above) can be used.