Skip to content

Instantly share code, notes, and snippets.

@gtrak
Last active August 29, 2015 13:57
Show Gist options
  • Save gtrak/9349175 to your computer and use it in GitHub Desktop.
Save gtrak/9349175 to your computer and use it in GitHub Desktop.
deps hack
(defn- compiled-files
[compiler-env]
(->> (for [[path js] (-> compiler-env deref :cljs.compiler/compiled-cljs)]
js)
cljs-deps/dependency-order))
(defn- compile-client-js [opts compiler-env]
(let [;; the options value used as an ifn somewhere in cljs.closure :-/
opts (-> (into {} opts)
;; TODO why isn't the :working-dir option for the brepl env
;; called :output-dir in the first place?
(assoc :output-dir (:working-dir opts))
(dissoc :source-map))]
(cljsc/build (reify cljsc/Compilable
(-compile [this _]
(concat (compiled-files compiler-env)
[(cljsc/-compile '[(ns clojure.browser.repl.client
(:require [goog.events :as event]
[clojure.browser.repl :as repl]))
(defn start [url]
(event/listen js/window
"load"
(fn []
(repl/start-evaluator url))))]
opts)])))
opts
compiler-env)))
(defn- create-client-js-file [opts file-path compiler-env]
(let [file (io/file file-path)]
(spit file (str (apply str (compiled-files compiler-env))
(with-out-str (compile-client-js (assoc opts :output-to :print) compiler-env))))
file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment