(compile-root src-dir)
(compile-root src-dir target-dir)
(compile-root src-dir target-dir opts)
Looks recursively in src-dir for .cljs files and compiles them to
.js files. If target-dir is provided, output will go into this
directory mirroring the source directory structure. Returns a list
of maps containing information about each file which was compiled
in dependency order.
Source
(defn compile-root
"Looks recursively in src-dir for .cljs files and compiles them to
.js files. If target-dir is provided, output will go into this
directory mirroring the source directory structure. Returns a list
of maps containing information about each file which was compiled
in dependency order."
([src-dir]
(compile-root src-dir "out"))
([src-dir target-dir]
(compile-root src-dir target-dir
(when env/*compiler*
(:options @env/*compiler*))))
([src-dir target-dir opts]
(swap! env/*compiler* assoc :root src-dir)
(let [src-dir-file (io/file src-dir)
inputs (deps/dependency-order
(map #(ana/parse-ns %)
(cljs-files-in src-dir-file)))]
(binding [*inputs* (zipmap (map :ns inputs) inputs)]
(loop [inputs (seq inputs) compiled []]
(if inputs
(let [{:keys [source-file] :as ns-info} (first inputs)
output-file (util/to-target-file target-dir ns-info)
ijs (compile-file source-file output-file opts)]
(recur
(next inputs)
(conj compiled
(assoc ijs :file-name (.getPath output-file)))))
compiled))))))