Skip to content

Commit eb9478c

Browse files
author
dnolen
committed
CLJS-1156: load-file fails with :make-reader issue
relax namespace checking, if something loaded a namesapce it's ok to refer to it, fixes interactions after load-file, no longer get false warnings load-file needs to use *repl-opts* if opts not supplied, load-file need to analyze the file in case it was already compiled.
1 parent f8fd08d commit eb9478c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@
429429
(defn confirm-ns [env ns-sym]
430430
(when (and (nil? (get '#{cljs.core goog Math goog.string} ns-sym))
431431
(nil? (get (-> env :ns :requires) ns-sym))
432+
;; something else may have loaded the namespace, i.e. load-file
433+
(nil? (get-in @env/*compiler* [::namespaces ns-sym]))
432434
;; macros may refer to namespaces never explicitly required
433435
;; confirm that the library at least exists
434436
(nil? (io/resource (util/ns->relpath ns-sym))))

src/clj/cljs/repl.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@
471471
;; TODO: this should probably compile dependencies - David
472472

473473
(defn load-file
474-
([repl-env f] (load-file repl-env f nil))
474+
([repl-env f] (load-file repl-env f *repl-opts*))
475475
([repl-env f opts]
476476
(if (:output-dir opts)
477477
(let [src (cond
@@ -482,6 +482,10 @@
482482
(assoc opts
483483
:output-file
484484
(cljsc/src-file->target-file src)))]
485+
;; make sure it's been analyzed, this is because if it's already compiled
486+
;; cljs.compiler/compile-file won't do anything, good for builds,
487+
;; but a bit annoying here
488+
(ana/analyze-file src opts)
485489
(-evaluate repl-env f 1 (cljsc/add-dep-string opts compiled))
486490
(-evaluate repl-env f 1 (cljsc/src-file->goog-require src)))
487491
(binding [ana/*cljs-ns* 'cljs.user]

0 commit comments

Comments
 (0)