Skip to content
Browse files
CLJS-1968: Enable calling JS modules that export a single function
  • Loading branch information
anmonteiro authored and swannodette committed Mar 10, 2017
1 parent 86f26bf commit 1d38f73a86081ad54cb230c507fbae183d768d6b
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/main/clojure/cljs/analyzer.cljc
@@ -691,8 +691,9 @@
;; we need to check both keys and values of the JS module index, because
;; macroexpansion will be looking for the provided name - António Monteiro
(-> (into #{} (mapcat identity) (get-in @env/*compiler* [:js-module-index]))
(contains? module)))
(into #{} (mapcat identity) (get-in @env/*compiler* [:js-module-index]))
(str module)))

(defn confirm-var-exists
([env prefix suffix]
@@ -711,7 +712,7 @@
(not (loaded-js-ns? env prefix))
(not (and (= 'cljs.core prefix) (= 'unquote suffix)))
(nil? (gets @env/*compiler* ::namespaces prefix :defs suffix))
(not (js-module-exists? (str prefix))))
(not (js-module-exists? prefix)))
(missing-fn env prefix suffix)))))

(defn confirm-var-exists-throw []
@@ -746,7 +747,7 @@
;; macros may refer to namespaces never explicitly required
;; confirm that the library at least exists
#?(:clj (nil? (util/ns->source ns-sym)))
(not (js-module-exists? (str ns-sym))))
(not (js-module-exists? ns-sym)))
(warning :undeclared-ns env {:ns-sym ns-sym})))

(defn core-name?
@@ -921,6 +922,13 @@
(some? (gets @env/*compiler* ::namespaces (-> env :ns :name) :imports sym))
(recur env (gets @env/*compiler* ::namespaces (-> env :ns :name) :imports sym) confirm)

(or (js-module-exists? s)
(js-module-exists? (resolve-ns-alias env s)))
(let [module (or (gets @env/*compiler* :js-module-index s)
(resolve-ns-alias env s))]
{:name (symbol module)
:ns 'js})

(let [cur-ns (-> env :ns :name)
full-ns (cond

0 comments on commit 1d38f73

Please sign in to comment.