Skip to content

Commit

Permalink
include source extension info in map returned by cljs.closure/source-…
Browse files Browse the repository at this point in the history
…for-namespace and

cljs.closure/cljs-source-for-namespace
  • Loading branch information
dnolen committed Jun 21, 2016
1 parent a46eea2 commit 37b5d7d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,14 @@
[ns]
(if (= "cljs.core$macros" (str ns))
(let [relpath "cljs/core.cljc"]
{:relative-path relpath :uri (io/resource relpath)})
{:relative-path relpath :uri (io/resource relpath) :ext :cljc})
(let [path (-> (munge ns) (string/replace \. \/))
relpath (str path ".cljs")]
(if-let [res (io/resource relpath)]
{:relative-path relpath :uri res}
{:relative-path relpath :uri res :ext :cljs}
(let [relpath (str path ".cljc")]
(if-let [res (io/resource relpath)]
{:relative-path relpath :uri res}))))))
{:relative-path relpath :uri res :ext :cljc}))))))

(defn source-for-namespace
"Given a namespace and compilation environment return the relative path and
Expand All @@ -660,13 +660,13 @@
path (string/replace ns-str \. \/)
relpath (str path ".cljs")]
(if-let [cljs-res (io/resource relpath)]
{:relative-path relpath :uri cljs-res}
{:relative-path relpath :uri cljs-res :ext :cljs}
(let [relpath (str path ".cljc")]
(if-let [cljc-res (io/resource relpath)]
{:relative-path relpath :uri cljc-res}
{:relative-path relpath :uri cljc-res :ext :cljc}
(let [relpath (str path ".js")]
(if-let [js-res (io/resource relpath)]
{:relative-path relpath :uri js-res}
{:relative-path relpath :uri js-res :ext :js}
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
relpath (or (:file ijs) (:url ijs))]
(if-let [js-res (and relpath
Expand All @@ -675,7 +675,7 @@
(or (and (util/url? relpath) relpath)
(try (URL. relpath) (catch Throwable t))
(io/resource relpath)))]
{:relative-path relpath :uri js-res}
{:relative-path relpath :uri js-res :ext :js}
(throw
(IllegalArgumentException.
(str "Namespace " ns " does not exist"))))))))))))
Expand Down

0 comments on commit 37b5d7d

Please sign in to comment.