Skip to content

Commit dd85919

Browse files
committed
- fix load-dependencies so we drop global namespaces
1 parent 53abd2c commit dd85919

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/clojure/cljs/repl.cljc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,20 @@
251251
(load-sources repl-env sources opts)
252252
sources)))
253253

254+
(defn global-ns? [x]
255+
(or (= 'js x)
256+
(= "js" (namespace x))))
257+
254258
(defn- load-dependencies
255259
"Compile and load the given `requires` and return the compiled sources."
256260
([repl-env requires]
257261
(load-dependencies repl-env requires nil))
258262
([repl-env requires opts]
259-
(doall (mapcat #(load-namespace repl-env % opts) (distinct requires)))))
263+
(->> requires
264+
distinct
265+
(remove global-ns?)
266+
(mapcat #(load-namespace repl-env % opts))
267+
doall)))
260268

261269
(defn ^File js-src->cljs-src
262270
"Map a JavaScript output file back to the original ClojureScript source
@@ -652,7 +660,7 @@
652660
(defn- wrap-fn [form]
653661
(cond
654662
(and (seq? form)
655-
(#{'ns 'require 'require-macros
663+
(#{'ns 'require 'require-macros 'refer-global
656664
'use 'use-macros 'import 'refer-clojure} (first form)))
657665
identity
658666

@@ -673,7 +681,7 @@
673681
(defn- init-wrap-fn [form]
674682
(cond
675683
(and (seq? form)
676-
(#{'ns 'require 'require-macros
684+
(#{'ns 'require 'require-macros 'refer-global
677685
'use 'use-macros 'import 'refer-clojure} (first form)))
678686
identity
679687

0 commit comments

Comments
 (0)