Skip to content

Commit 1d16bc5

Browse files
author
dnolen
committed
CLJS-2229: Ensure that new modules work works correctly with REPLs
1. when processing ns forms we need to check if we need to process js modules. This potentially requires two passes in the second pass suppresss dupe alias check which would otherwise get fired due to rewriting the alias to the generated Closure module name. 2. We need to apply a simpler strategy to transitive dependencies. When we've determined all the sources, call handle-js-modules deps on these.
1 parent 914b9b1 commit 1d16bc5

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/main/clojure/cljs/repl.cljc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
(remove (comp #{["goog"]} :provides))
197197
(remove (comp #{:seed} :type))
198198
(map #(select-keys % [:provides :url])))]
199-
(cljsc/handle-js-modules opts sources env/*compiler* false)
199+
(cljsc/handle-js-modules opts sources env/*compiler*)
200200
(if (:output-dir opts)
201201
;; REPLs that read from :output-dir just need to add deps,
202202
;; environment will handle actual loading - David
@@ -454,9 +454,17 @@
454454
:source-form form}
455455
:repl-env repl-env})
456456
def-emits-var (:def-emits-var opts)
457-
ast (binding [ana/*analyze-deps* false]
458-
(ana/analyze (assoc env :def-emits-var def-emits-var)
459-
(wrap form) nil opts))
457+
->ast (fn [form]
458+
(binding [ana/*analyze-deps* false]
459+
(ana/analyze (assoc env :def-emits-var def-emits-var)
460+
(wrap form) nil opts)))
461+
ast (->ast form)
462+
ast (if-not (#{:ns :ns*} (:op ast))
463+
ast
464+
(let [ijs (ana/parse-ns [form])] ;; if ns form need to check for js modules - David
465+
(cljsc/handle-js-modules opts [ijs] env/*compiler*)
466+
(binding [ana/*check-alias-dupes* false]
467+
(ana/no-warn (->ast form)))))
460468
wrap-js
461469
;; TODO: check opts as well - David
462470
(if (:source-map repl-env)
@@ -857,7 +865,6 @@
857865
(let [value (eval repl-env env input opts)]
858866
(print value))))))]
859867
(cljsc/maybe-install-node-deps! opts)
860-
(cljsc/handle-js-modules opts '() env/*compiler* false)
861868
(comp/with-core-cljs opts
862869
(fn []
863870
(binding [*repl-opts* opts]

0 commit comments

Comments
 (0)