Skip to content

Commit 5353489

Browse files
committed
CLJS-1203: official way to supply multiple files/directories to cljs.closure/build and cljs.closure/watch
Add cljs.build.api/inputs which returns cljs.closure/Compilable instance Add cljs.build.api/build, will eventually become the only public entry point for building
1 parent c7082b4 commit 5353489

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/clj/cljs/build/api.clj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
[clojure.java.io :as io])
2222
(:import java.io.File))
2323

24+
;; =============================================================================
25+
;; Useful Utilities
26+
2427
(defn ^File target-file-for-cljs-ns
2528
"Given an output directory and a clojurescript namespace return the
2629
compilation target file for that namespace.
@@ -90,6 +93,30 @@
9093
([src options]
9194
(closure/src-file->goog-require src options)))
9295

96+
;; =============================================================================
97+
;; Main API
98+
99+
(defn inputs
100+
"Given a list of directories and files, return a compilable object that may
101+
be passed to build or watch."
102+
[& xs]
103+
(reify
104+
closure/Compilable
105+
(-compile [_ opts]
106+
(letfn [(compile-input [x]
107+
(let [compiled (closure/-compile x opts)]
108+
(if (sequential? compiled)
109+
compiled
110+
[compiled])))]
111+
(mapcat compile-input xs)))))
112+
113+
(defn build
114+
"Given a source which can be compiled, produce runnable JavaScript."
115+
([source opts]
116+
(closure/build source opts))
117+
([source opts compiler-env]
118+
(closure/build source opts compiler-env)))
119+
93120
(comment
94121

95122
(def test-cenv (atom {}))

0 commit comments

Comments
 (0)