(defn confirm-ns
"Given env, an analysis environment, and ns-sym, a symbol identifying a
namespace, confirm that the namespace exists. Warn if not found."
[env ns-sym]
(when (and (not= 'cljs.core ns-sym)
(nil? (get implicit-nses ns-sym))
(nil? (get (-> env :ns :requires) ns-sym))
;; something else may have loaded the namespace, i.e. load-file
(nil? (gets @env/*compiler* ::namespaces ns-sym))
;; 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? ns-sym)))
(warning :undeclared-ns env {:ns-sym ns-sym :js-provide ns-sym})))