Skip to content

Commit ce6c657

Browse files
anmonteiroswannodette
authored andcommitted
CLJS-1772: Dependency index can incorrectly overwrite .cljs files with .cljc files if both are present
1 parent ddf1836 commit ce6c657

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: src/main/clojure/cljs/js_deps.cljc

+12-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,18 @@ case."
133133
(fn [index' provide]
134134
(if (:foreign dep)
135135
(update-in index' [provide] merge dep)
136-
(assoc index' provide dep)))
136+
;; when building the dependency index, we need to
137+
;; avoid overwriting a CLJS dep with a CLJC dep of
138+
;; the same namespace - António Monteiro
139+
(let [file (when-let [f (or (:source-file dep) (:file dep))]
140+
(.toString f))
141+
ext (when file
142+
(.substring file (inc (.lastIndexOf file "."))))]
143+
(update-in index' [provide]
144+
(fn [d]
145+
(if (and (= ext "cljc") (some? d))
146+
d
147+
dep))))))
137148
index provides)
138149
index)]
139150
(if (:foreign dep)

0 commit comments

Comments
 (0)