Skip to content

Commit 1f5e795

Browse files
committed
CLJS-2244: Orphaned processed JS modules breaks :modules
Handle processed JS libs whose :lib-path is in the output directory specially when computing module uris
1 parent aca54ad commit 1f5e795

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/clojure/cljs/module_graph.cljc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,23 @@
263263
add-cljs-base add-cljs-base-dep)))
264264
)
265265

266+
(defn parent? [f0 f1]
267+
(.startsWith
268+
(.getAbsolutePath (io/file f0))
269+
(.getAbsolutePath (io/file f1))))
270+
271+
;; JS modules become Closure libs that exist in the output directory. However in
272+
;; the current indexing pipeline, these will not have an :out-file. Correct these
273+
;; entries for module->module-uris - David
274+
275+
(defn maybe-add-out-file
276+
[{:keys [lib-path] :as ijs} {:keys [output-dir] :as opts}]
277+
(if-not lib-path
278+
ijs
279+
(if (parent? lib-path output-dir)
280+
(assoc ijs :out-file lib-path)
281+
ijs)))
282+
266283
(defn modules->module-uris
267284
"Given a :modules map, a dependency sorted list of compiler inputs, and
268285
compiler options return a Closure module uris map. This map will include
@@ -293,7 +310,8 @@
293310
(fn [{:keys [out-file] :as ijs}]
294311
(if-not out-file
295312
(throw (Exception. (str "No :out-file for IJavaScript " (pr-str ijs))))
296-
out-file))))
313+
out-file))
314+
#(maybe-add-out-file % opts)))
297315
(distinct))
298316
entries)]))
299317
(expand-modules modules inputs))

0 commit comments

Comments
 (0)