(require '[cljs.build.api :as b]
'[clojure.java.io :as io])
(refer 'cljs.closure :only '[js-transforms])
(import 'javax.script.ScriptEngineManager)
(defmethod js-transforms :jsx [ijs opts]
(let [engine (doto (.getEngineByName (ScriptEngineManager.) "nashorn")
(.eval (io/reader (io/file "babel.min.js")))
(.put "input" (:source ijs)))]
(assoc ijs :source
(.eval engine (str "Babel.transform(input, {presets: ['react']}).code")))))
(b/build "src"
{:main 'my-project.core
:output-to "out/my_project.js"
:output-dir "out"
:foreign-libs [{:file "libs/example.js"
:provides ["my.example"]
:preprocess :jsx}]})