Skip to content

Commit b7895ae

Browse files
committed
CLJS-3259: revert public api change made in 45022fa
Restore checking for a bound compiler state.
1 parent 6691bae commit b7895ae

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

src/main/clojure/cljs/analyzer/api.cljc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
([env form] (analyze env form nil))
135135
([env form name] (analyze env form name nil))
136136
([env form name opts]
137-
(analyze (empty-state opts) env form name opts))
137+
(analyze (or (current-state) (empty-state opts)) env form name opts))
138138
([state env form name opts]
139139
(env/with-compiler-env state
140140
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -161,7 +161,7 @@
161161
([src] (parse-ns src nil nil))
162162
([src opts] (parse-ns src nil opts))
163163
([src dest opts]
164-
(parse-ns (empty-state opts) src dest opts))
164+
(parse-ns (or (current-state) (empty-state opts)) src dest opts))
165165
([state src dest opts]
166166
(env/with-compiler-env state
167167
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -178,7 +178,7 @@
178178
meaningful value."
179179
([f] (analyze-file f nil))
180180
([f opts]
181-
(analyze-file (empty-state opts) f opts))
181+
(analyze-file (or (current-state) (empty-state opts)) f opts))
182182
([state f opts]
183183
(env/with-compiler-env state
184184
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]

src/main/clojure/cljs/build/api.clj

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
('example.core 'example.util)"
5353
([namespaces]
5454
(closure/cljs-dependents-for-macro-namespaces
55-
(ana-api/empty-state) namespaces))
55+
(or (ana-api/current-state) (ana-api/empty-state)) namespaces))
5656
([state namespaces]
5757
(closure/cljs-dependents-for-macro-namespaces state namespaces)))
5858

@@ -68,7 +68,8 @@
6868
provide build options with :output-dir specified."
6969
([src] (src-file->target-file src nil))
7070
([src opts]
71-
(src-file->target-file (ana-api/empty-state opts) src opts))
71+
(src-file->target-file
72+
(or (ana-api/current-state) (ana-api/empty-state opts)) src opts))
7273
([state src opts]
7374
(ana-api/with-state state
7475
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -79,7 +80,8 @@
7980
the goog.require statement for it."
8081
([src] (src-file->goog-require src nil))
8182
([src opts]
82-
(src-file->goog-require (ana-api/empty-state opts) src opts))
83+
(src-file->goog-require
84+
(or (ana-api/current-state) (ana-api/empty-state opts)) src opts))
8385
([state src opts]
8486
(ana-api/with-state state
8587
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -121,7 +123,7 @@
121123
.cljs, .cljc, .js. Returns a map containing :relative-path a string, and
122124
:uri a URL."
123125
([ns]
124-
(ns->location ns (ana-api/empty-state)))
126+
(ns->location ns (or (ana-api/current-state) (ana-api/empty-state))))
125127
([ns compiler-env]
126128
(closure/source-for-namespace ns compiler-env)))
127129

@@ -139,7 +141,7 @@
139141
([xs]
140142
(add-dependency-sources xs {}))
141143
([xs opts]
142-
(add-dependency-sources (ana-api/empty-state opts) xs opts))
144+
(add-dependency-sources (or (ana-api/current-state) (ana-api/empty-state opts)) xs opts))
143145
([state xs opts]
144146
(ana-api/with-state state
145147
(closure/add-dependency-sources xs opts))))
@@ -192,7 +194,7 @@
192194
(defn compile
193195
"Given a Compilable, compile it and return an IJavaScript."
194196
([opts compilable]
195-
(compile (ana-api/empty-state opts) opts compilable))
197+
(compile (or (ana-api/current-state) (ana-api/empty-state opts)) opts compilable))
196198
([state opts compilable]
197199
(ana-api/with-state state
198200
(closure/compile compilable opts))))
@@ -214,11 +216,13 @@
214216
(build nil opts))
215217
([source opts]
216218
(build source opts
217-
(ana-api/empty-state
218-
;; need to dissoc :foreign-libs since we won't know what overriding
219-
;; foreign libspecs are referring to until after add-implicit-options
220-
;; - David
221-
(closure/add-externs-sources (dissoc opts :foreign-libs)))))
219+
(or
220+
(ana-api/current-state)
221+
(ana-api/empty-state
222+
;; need to dissoc :foreign-libs since we won't know what overriding
223+
;; foreign libspecs are referring to until after add-implicit-options
224+
;; - David
225+
(closure/add-externs-sources (dissoc opts :foreign-libs))))))
222226
([source opts compiler-env]
223227
(doseq [[unknown-opt suggested-opt] (util/unknown-opts (set (keys opts)) closure/known-opts)]
224228
(when suggested-opt
@@ -230,8 +234,9 @@
230234
"Given a source which can be compiled, watch it for changes to produce."
231235
([source opts]
232236
(watch source opts
233-
(ana-api/empty-state
234-
(closure/add-externs-sources opts))))
237+
(or (ana-api/current-state)
238+
(ana-api/empty-state
239+
(closure/add-externs-sources opts)))))
235240
([source opts compiler-env]
236241
(watch source opts compiler-env nil))
237242
([source opts compiler-env stop]
@@ -291,12 +296,14 @@
291296
installed."
292297
([entries]
293298
(node-inputs entries
294-
(:options (ana-api/empty-state))))
299+
(:options (or (ana-api/current-state) (ana-api/empty-state)))))
295300
([entries opts]
296301
(closure/node-inputs entries opts)))
297302

298303
(defn node-modules
299304
"Return a sequence of requirable libraries found under node_modules."
305+
([]
306+
(node-modules {}))
300307
([opts]
301-
(ana-api/with-state (ana-api/empty-state opts)
308+
(ana-api/with-state (or (ana-api/current-state) (ana-api/empty-state opts))
302309
(filter :provides (closure/index-node-modules-dir)))))

src/main/clojure/cljs/compiler/api.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(defn emit
2727
"Given an AST node generated by the analyzer emit JavaScript as a string."
2828
([ast]
29-
(emit (ana-api/empty-state) ast))
29+
(emit (or (ana-api/current-state) (ana-api/empty-state)) ast))
3030
([state ast]
3131
(ana-api/with-state state
3232
(with-out-str
@@ -40,7 +40,7 @@
4040
(:options @state))))
4141
([opts] (with-core-cljs opts (fn [])))
4242
([opts body]
43-
(with-core-cljs (ana-api/empty-state opts) opts body))
43+
(with-core-cljs (or (ana-api/current-state) (ana-api/empty-state opts)) opts body))
4444
([state opts body]
4545
(ana-api/with-state state
4646
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -50,7 +50,7 @@
5050
"Return true if the src file requires compilation."
5151
([src dest] (requires-compilation? src dest nil))
5252
([src dest opts]
53-
(requires-compilation? (ana-api/empty-state opts) src dest opts))
53+
(requires-compilation? (or (ana-api/current-state)(ana-api/empty-state opts)) src dest opts))
5454
([state src dest opts]
5555
(ana-api/with-state state
5656
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -74,7 +74,7 @@
7474
([src dest]
7575
(compile-file src dest nil))
7676
([src dest opts]
77-
(compile-file (ana-api/empty-state opts) src dest opts))
77+
(compile-file (or (ana-api/current-state) (ana-api/empty-state opts)) src dest opts))
7878
([state src dest opts]
7979
(ana-api/with-state state
8080
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]
@@ -94,7 +94,7 @@
9494
([src-dir] (compile-root src-dir "out"))
9595
([src-dir target-dir] (compile-root src-dir target-dir nil))
9696
([src-dir target-dir opts]
97-
(compile-root (ana-api/empty-state opts) src-dir target-dir opts))
97+
(compile-root (or (ana-api/current-state) (ana-api/empty-state opts)) src-dir target-dir opts))
9898
([state src-dir target-dir opts]
9999
(ana-api/with-state state
100100
(binding [ana/*cljs-warning-handlers* (:warning-handlers opts ana/*cljs-warning-handlers*)]

0 commit comments

Comments
 (0)