|
57 | 57 | 'example.macros :
|
58 | 58 | (cljs-dependents-for-macro-namespaces 'example.macros) ->
|
59 | 59 | ('example.core 'example.util)"
|
60 |
| - ([namespaces] (cljs-dependents-for-macro-namespaces env/*compiler* namespaces)) |
| 60 | + ([namespaces] |
| 61 | + (cljs-dependents-for-macro-namespaces |
| 62 | + (if-not (nil? env/*compiler*) |
| 63 | + env/*compiler* |
| 64 | + (env/default-compiler-env)) |
| 65 | + namespaces)) |
61 | 66 | ([state namespaces]
|
62 | 67 | (map :name
|
63 |
| - (let [namespaces-set (set namespaces)] |
64 |
| - (filter (fn [x] (not-empty |
65 |
| - (intersection namespaces-set (-> x :require-macros vals set)))) |
66 |
| - (vals (:cljs.analyzer/namespaces @state))))))) |
| 68 | + (let [namespaces-set (set namespaces)] |
| 69 | + (filter (fn [x] (not-empty |
| 70 | + (intersection namespaces-set (-> x :require-macros vals set)))) |
| 71 | + (vals (:cljs.analyzer/namespaces @state))))))) |
67 | 72 |
|
68 | 73 | (defn cljs-ns-dependents
|
69 | 74 | "Given a namespace symbol return a seq of all dependent
|
70 | 75 | namespaces sorted in dependency order. Will include
|
71 | 76 | transient dependents."
|
72 |
| - ([ns] (cljs-ns-dependents env/*compiler* ns)) |
| 77 | + ([ns] |
| 78 | + (cljs-ns-dependents |
| 79 | + (if-not (nil? env/*compiler*) |
| 80 | + env/*compiler* |
| 81 | + (env/default-compiler-env)) |
| 82 | + ns)) |
73 | 83 | ([state ns]
|
74 | 84 | (env/with-compiler-env state
|
75 | 85 | (ana/ns-dependents ns))))
|
|
85 | 95 | "Given a ClojureScript source file return the target file. May optionally
|
86 | 96 | provide build options with :output-dir specified."
|
87 | 97 | ([src] (src-file->target-file src nil))
|
88 |
| - ([src opts] (src-file->target-file env/*compiler* src opts)) |
| 98 | + ([src opts] |
| 99 | + (src-file->target-file |
| 100 | + (if-not (nil? env/*compiler*) |
| 101 | + env/*compiler* |
| 102 | + (env/default-compiler-env opts)) |
| 103 | + src opts)) |
89 | 104 | ([state src opts]
|
90 | 105 | (env/with-compiler-env state
|
91 | 106 | (binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
|
|
95 | 110 | "Given a ClojureScript or Google Closure style JavaScript source file return
|
96 | 111 | the goog.require statement for it."
|
97 | 112 | ([src] (src-file->goog-require src nil))
|
98 |
| - ([src options] (src-file->goog-require env/*compiler* src options)) |
| 113 | + ([src options] |
| 114 | + (src-file->goog-require |
| 115 | + (if-not (nil? env/*compiler*) |
| 116 | + env/*compiler* |
| 117 | + (env/default-compiler-env)) |
| 118 | + src options)) |
99 | 119 | ([state src options]
|
100 | 120 | (env/with-compiler-env state
|
101 | 121 | (binding [ana/*cljs-warning-handlers* (:warning-handlers options ana/*cljs-warning-handlers*)]
|
|
126 | 146 | uri of the corresponding source regardless of the source language extension:
|
127 | 147 | .cljs, .cljc, .js. Returns a map containing :relative-path a string, and
|
128 | 148 | :uri a URL."
|
129 |
| - ([ns] (ns->location ns env/*compiler*)) |
| 149 | + ([ns] |
| 150 | + (ns->location ns |
| 151 | + (if-not (nil? env/*compiler*) |
| 152 | + env/*compiler* |
| 153 | + (env/default-compiler-env)))) |
130 | 154 | ([ns compiler-env]
|
131 | 155 | (closure/source-for-namespace ns compiler-env)))
|
132 | 156 |
|
|
163 | 187 |
|
164 | 188 | (defn compile
|
165 | 189 | "Given a Compilable, compile it and return an IJavaScript."
|
166 |
| - ([opts compilable] (compile env/*compiler* opts compilable)) |
| 190 | + ([opts compilable] |
| 191 | + (compile |
| 192 | + (if-not (nil? env/*compiler*) |
| 193 | + env/*compiler* |
| 194 | + (env/default-compiler-env opts)) |
| 195 | + opts compilable)) |
167 | 196 | ([state opts compilable]
|
168 | 197 | (env/with-compiler-env state
|
169 | 198 | (closure/compile compilable opts))))
|
|
181 | 210 | (defn build
|
182 | 211 | "Given a source which can be compiled, produce runnable JavaScript."
|
183 | 212 | ([source opts]
|
184 |
| - (build source opts nil)) |
| 213 | + (build source opts |
| 214 | + (if-not (nil? env/*compiler*) |
| 215 | + env/*compiler* |
| 216 | + (env/default-compiler-env opts)))) |
185 | 217 | ([source opts compiler-env]
|
186 | 218 | (binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
|
187 | 219 | (closure/build source opts compiler-env))))
|
188 | 220 |
|
189 | 221 | (defn watch
|
190 | 222 | "Given a source which can be compiled, watch it for changes to produce."
|
191 | 223 | ([source opts]
|
192 |
| - (watch source opts (if-not (nil? env/*compiler*) |
193 |
| - env/*compiler* |
194 |
| - (env/default-compiler-env opts)))) |
| 224 | + (watch source opts |
| 225 | + (if-not (nil? env/*compiler*) |
| 226 | + env/*compiler* |
| 227 | + (env/default-compiler-env opts)))) |
195 | 228 | ([source opts compiler-env]
|
196 | 229 | (watch source opts compiler-env nil))
|
197 | 230 | ([source opts compiler-env stop]
|
|
0 commit comments