(defn invokeable-ns?
"Returns true if ns is a required namespace and a JavaScript module that
might be invokeable as a function."
[ns env]
(let [ns (resolve-ns-alias env ns)]
(and (required? ns env)
(or (js-module-exists? ns)
(node-module-dep? ns)
(dep-has-global-exports? ns)))))