|
234 | 234 | (dissoc opts :macros-ns)
|
235 | 235 | cb))
|
236 | 236 |
|
237 |
| -(defn post-file-side-effects |
| 237 | +(defn- pre-file-side-effects |
| 238 | + [st name file opts] |
| 239 | + (when (:verbose opts) |
| 240 | + (debug-prn "Pre-file side-effects" file)) |
| 241 | + ;; In case any constants are defined in the namespace, flush any analysis metadata |
| 242 | + ;; so that the constants can be defined wihtout triggering re-defined errors. |
| 243 | + (when (and (get-in @st [::ana/namespaces name :defs]) |
| 244 | + (not ('#{cljs.core cljs.core$macros} name))) |
| 245 | + (swap! st update ::ana/namespaces dissoc name))) |
| 246 | + |
| 247 | +(defn- post-file-side-effects |
238 | 248 | [file opts]
|
239 | 249 | (when (:verbose opts)
|
240 | 250 | (debug-prn "Post-file side-effects" file))
|
|
279 | 289 | (if resource
|
280 | 290 | (let [{:keys [lang source cache source-map file]} resource]
|
281 | 291 | (condp = lang
|
282 |
| - :clj (eval-str* bound-vars source name (assoc opts :cljs-file file) |
283 |
| - (fn [res] |
284 |
| - (post-file-side-effects file opts) |
285 |
| - (if (:error res) |
286 |
| - (cb res) |
287 |
| - (do |
288 |
| - (swap! *loaded* conj aname) |
289 |
| - (cb {:value true}))))) |
| 292 | + :clj (do |
| 293 | + (pre-file-side-effects (:*compiler* bound-vars) aname file opts) |
| 294 | + (eval-str* bound-vars source name (assoc opts :cljs-file file) |
| 295 | + (fn [res] |
| 296 | + (post-file-side-effects file opts) |
| 297 | + (if (:error res) |
| 298 | + (cb res) |
| 299 | + (do |
| 300 | + (swap! *loaded* conj aname) |
| 301 | + (cb {:value true})))))) |
290 | 302 | :js (process-macros-deps bound-vars cache opts
|
291 | 303 | (fn [res]
|
292 | 304 | (if (:error res)
|
|
416 | 428 | (if resource
|
417 | 429 | (let [{:keys [name lang source file]} resource]
|
418 | 430 | (condp = lang
|
419 |
| - :clj (analyze-str* bound-vars source name (assoc opts :cljs-file file) |
420 |
| - (fn [res] |
421 |
| - (post-file-side-effects file opts) |
422 |
| - (if-not (:error res) |
423 |
| - (analyze-deps bound-vars ana-env lib (next deps) opts cb) |
424 |
| - (cb res)))) |
| 431 | + :clj (do |
| 432 | + (pre-file-side-effects (:*compiler* bound-vars) name file opts) |
| 433 | + (analyze-str* bound-vars source name (assoc opts :cljs-file file) |
| 434 | + (fn [res] |
| 435 | + (post-file-side-effects file opts) |
| 436 | + (if-not (:error res) |
| 437 | + (analyze-deps bound-vars ana-env lib (next deps) opts cb) |
| 438 | + (cb res))))) |
425 | 439 | :js (analyze-deps bound-vars ana-env lib (next deps) opts cb)
|
426 | 440 | (wrap-error
|
427 | 441 | (ana/error ana-env
|
|
0 commit comments