Skip to content

Commit 37b5d7d

Browse files
author
dnolen
committed
include source extension info in map returned by cljs.closure/source-for-namespace and
cljs.closure/cljs-source-for-namespace
1 parent a46eea2 commit 37b5d7d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/clojure/cljs/closure.clj

+7-7
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,14 @@
642642
[ns]
643643
(if (= "cljs.core$macros" (str ns))
644644
(let [relpath "cljs/core.cljc"]
645-
{:relative-path relpath :uri (io/resource relpath)})
645+
{:relative-path relpath :uri (io/resource relpath) :ext :cljc})
646646
(let [path (-> (munge ns) (string/replace \. \/))
647647
relpath (str path ".cljs")]
648648
(if-let [res (io/resource relpath)]
649-
{:relative-path relpath :uri res}
649+
{:relative-path relpath :uri res :ext :cljs}
650650
(let [relpath (str path ".cljc")]
651651
(if-let [res (io/resource relpath)]
652-
{:relative-path relpath :uri res}))))))
652+
{:relative-path relpath :uri res :ext :cljc}))))))
653653

654654
(defn source-for-namespace
655655
"Given a namespace and compilation environment return the relative path and
@@ -660,13 +660,13 @@
660660
path (string/replace ns-str \. \/)
661661
relpath (str path ".cljs")]
662662
(if-let [cljs-res (io/resource relpath)]
663-
{:relative-path relpath :uri cljs-res}
663+
{:relative-path relpath :uri cljs-res :ext :cljs}
664664
(let [relpath (str path ".cljc")]
665665
(if-let [cljc-res (io/resource relpath)]
666-
{:relative-path relpath :uri cljc-res}
666+
{:relative-path relpath :uri cljc-res :ext :cljc}
667667
(let [relpath (str path ".js")]
668668
(if-let [js-res (io/resource relpath)]
669-
{:relative-path relpath :uri js-res}
669+
{:relative-path relpath :uri js-res :ext :js}
670670
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
671671
relpath (or (:file ijs) (:url ijs))]
672672
(if-let [js-res (and relpath
@@ -675,7 +675,7 @@
675675
(or (and (util/url? relpath) relpath)
676676
(try (URL. relpath) (catch Throwable t))
677677
(io/resource relpath)))]
678-
{:relative-path relpath :uri js-res}
678+
{:relative-path relpath :uri js-res :ext :js}
679679
(throw
680680
(IllegalArgumentException.
681681
(str "Namespace " ns " does not exist"))))))))))))

0 commit comments

Comments
 (0)