Skip to content

Commit 616966c

Browse files
committed
CLJS-2659: Unable to require namespaces that require node modules in node cljs repl
Fixes the non-Node.js case. handle-js-modules *must* update compiler `:options`. If this isn't done, the future compilation runs will return different results.
1 parent 8953f46 commit 616966c

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/main/clojure/cljs/closure.clj

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,15 +2636,17 @@
26362636
(:foreign-libs opts)))
26372637
(process-js-modules opts)
26382638
(:options @compiler-env))]
2639-
(swap! compiler-env (fn [cenv]
2640-
(-> cenv
2641-
;; we need to also track the whole top level - this is to support
2642-
;; cljs.analyze/analyze-deps, particularly in REPL contexts - David
2643-
(merge {:js-dependency-index (deps/js-dependency-index opts)})
2644-
(update-in [:node-module-index] (fnil into #{})
2645-
(if (= target :nodejs)
2646-
(map str node-required)
2647-
(map str (keys top-level)))))))
2639+
(swap! compiler-env
2640+
(fn [cenv]
2641+
(-> cenv
2642+
;; we need to also track the whole top level - this is to support
2643+
;; cljs.analyze/analyze-deps, particularly in REPL contexts - David
2644+
(merge {:js-dependency-index (deps/js-dependency-index opts)})
2645+
(update-in [:options] merge opts)
2646+
(update-in [:node-module-index] (fnil into #{})
2647+
(if (= target :nodejs)
2648+
(map str node-required)
2649+
(map str (keys top-level)))))))
26482650
opts))
26492651

26502652
(defn output-bootstrap [{:keys [target] :as opts}]
@@ -2667,8 +2669,6 @@
26672669
(#(map add-core-macros-if-cljs-js %))
26682670
(add-js-sources opts) deps/dependency-order
26692671
(->> (map #(source-on-disk opts %)) doall))]
2670-
;; this is an optimization for handle-js-modules
2671-
(swap! env/*compiler* update-in [:options] merge opts)
26722672
sources)))
26732673

26742674
(defn compile-ns
@@ -2768,7 +2768,6 @@
27682768
(-> (-find-sources source opts)
27692769
(add-dependency-sources compile-opts)))
27702770
opts (handle-js-modules opts js-sources compiler-env)
2771-
_ (swap! env/*compiler* update-in [:options] merge opts)
27722771
js-sources (-> js-sources
27732772
deps/dependency-order
27742773
(compile-sources compiler-stats compile-opts)

0 commit comments

Comments
 (0)