Can You Mix ClojureScript and JVM-Clojure in The Same Project?

814 Views Asked by At

I understand that their is Clojure the sits on the JVM in which you can use Java libraries. Also, there is ClojureScript which allows you to use JavaScript libraries, but is it possible to mix libraries from each in one Clojure file / project?

1

There are 1 best solutions below

0
Daniel Compton On

You can write Clojure in .cljc files which can be read by both Clojure and ClojureScript. Any platform specific code can be wrapped in Reader Conditionals so it is only read on the host platform. Many libraries support cljc, though they do need to be converted, and it may not always make sense to do so if there is not a lot of common code between the two. See http://clojure.org/guides/reader_conditionals for more information.