|
83 | 83 | "Converts a namespaced symbol to a var, loading the requisite namespace if
|
84 | 84 | needed. For use with a function defined under a keyword in opts. The kw and
|
85 | 85 | ex-data arguments are used to form exceptions."
|
86 |
| - [sym kw ex-data] |
87 |
| - (let [ns (namespace sym) |
88 |
| - _ (when (nil? ns) |
89 |
| - (throw |
90 |
| - (ex-info (str kw " symbol " sym " is not fully qualified") |
91 |
| - (merge ex-data {kw sym |
92 |
| - :clojure.error/phase :compilation})))) |
93 |
| - var-ns (symbol ns)] |
94 |
| - (when (not (find-ns var-ns)) |
95 |
| - (try |
96 |
| - (locking ana/load-mutex |
97 |
| - (require var-ns)) |
98 |
| - (catch Throwable t |
99 |
| - (throw (ex-info (str "Cannot require namespace referred by " kw " value " sym) |
100 |
| - (merge ex-data {kw sym |
101 |
| - :clojure.error/phase :compilation}) |
102 |
| - t))))) |
103 |
| - |
104 |
| - (find-var sym))) |
| 86 | + ([sym kw] |
| 87 | + (sym->var sym kw nil)) |
| 88 | + ([sym kw ex-data] |
| 89 | + (let [ns (namespace sym) |
| 90 | + _ (when (nil? ns) |
| 91 | + (throw |
| 92 | + (ex-info (str kw " symbol " sym " is not fully qualified") |
| 93 | + (merge ex-data {kw sym |
| 94 | + :clojure.error/phase :compilation})))) |
| 95 | + var-ns (symbol ns)] |
| 96 | + (when (not (find-ns var-ns)) |
| 97 | + (try |
| 98 | + (locking ana/load-mutex |
| 99 | + (require var-ns)) |
| 100 | + (catch Throwable t |
| 101 | + (throw (ex-info (str "Cannot require namespace referred by " kw " value " sym) |
| 102 | + (merge ex-data {kw sym |
| 103 | + :clojure.error/phase :compilation}) |
| 104 | + t))))) |
| 105 | + |
| 106 | + (find-var sym)))) |
105 | 107 |
|
106 | 108 | (defn- opts-fn
|
107 | 109 | "Extracts a function from opts, by default expecting a function value, but
|
|
2483 | 2485 | [(if (symbol? k) (str (comp/munge k)) k) v])
|
2484 | 2486 | defines)))
|
2485 | 2487 |
|
| 2488 | +(defn resolve-warning-handlers [fns] |
| 2489 | + (reduce |
| 2490 | + (fn [ret afn] |
| 2491 | + (cond |
| 2492 | + (fn? afn) (conj ret afn) |
| 2493 | + |
| 2494 | + (symbol? afn) |
| 2495 | + (let [afn' (sym->var afn :warning-handlers)] |
| 2496 | + (when-not afn' |
| 2497 | + (throw |
| 2498 | + (ex-info (str "Could not resolve warning handler: " afn) |
| 2499 | + {:warning-handlers fns |
| 2500 | + :clojure.error/phase :compilation}))) |
| 2501 | + (conj ret afn')) |
| 2502 | + |
| 2503 | + :else |
| 2504 | + (throw |
| 2505 | + (ex-info (str "Invalid warning handler " afn " of type " (type afn)) |
| 2506 | + {:warning-handlers fns |
| 2507 | + :clojure.error/phase :compilation})))) |
| 2508 | + [] fns)) |
| 2509 | + |
2486 | 2510 | (defn add-implicit-options
|
2487 | 2511 | [{:keys [optimizations output-dir]
|
2488 | 2512 | :or {optimizations :none
|
|
2586 | 2610 | opts)))
|
2587 | 2611 |
|
2588 | 2612 | (nil? (:ignore-js-module-exts opts))
|
2589 |
| - (assoc :ignore-js-module-exts [".css"])))) |
| 2613 | + (assoc :ignore-js-module-exts [".css"]) |
| 2614 | + |
| 2615 | + (:warning-handlers opts) |
| 2616 | + (update :warning-handlers resolve-warning-handlers)))) |
2590 | 2617 |
|
2591 | 2618 | (defn- alive? [proc]
|
2592 | 2619 | (try (.exitValue proc) false (catch IllegalThreadStateException _ true)))
|
|
0 commit comments