(defn ^File to-target-file
([target-dir ns-info]
(to-target-file target-dir ns-info "js"))
([target-dir {:keys [ns source-file] :as ns-info} ext]
(let [src-ext (if source-file
(cljs.util/ext source-file)
"cljs")
ns (if (or (= src-ext "clj")
(and (= ns 'cljs.core) (= src-ext "cljc")))
(symbol (str ns "$macros"))
ns)
relpath (string/split (munge-path (str ns)) #"\.")
parents (cond-> (butlast relpath)
target-dir (conj target-dir))]
(cond->> (io/file (str (last relpath) (str "." ext)))
(seq parents)
(io/file (to-path parents))))))