Skip to content

Commit

Permalink
CLJS-2143: Automatically load ns needed by namespaced :preprocess keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Jul 4, 2017
1 parent d75b253 commit 9866a33
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/clojure/cljs/closure.clj
Expand Up @@ -1626,8 +1626,22 @@
(:preprocess ijs)))

(defmethod js-transforms :default [ijs opts]
(ana/warning :unsupported-preprocess-value @env/*compiler* ijs)
ijs)
;; If preprocess key is namespaced keyword,
;; and namespace pointed by the keyword namespace can
;; be required, try to run js-transforms again.
;; ::js-transform-required prevents this being called repeatedly,
;; if the ns doesn't provide the needed method.
(if (and (not (::js-transform-required opts))
(keyword (:preprocess ijs))
(namespace (:preprocess ijs))
(try
(require (symbol (namespace (:preprocess ijs))))
true
(catch Exception _
false)))
(js-transforms ijs (assoc opts ::js-transform-required true))
(do (ana/warning :unsupported-preprocess-value @env/*compiler* ijs)
ijs)))

(defn write-javascript
"Write or copy a JavaScript file to output directory. Only write if the file
Expand Down

0 comments on commit 9866a33

Please sign in to comment.