Skip to content

Commit 5858966

Browse files
committed
CLJS-1168: REPL fails to find .js files in :libs
Improve undeclared ns error reporting to account for :libs. :libs IJavaScript instance do not supply :file only :url. Enhance cljs.closure/source-for-namespace so it handles IJavaScript instances that do not supply :file.
1 parent 159fad2 commit 5858966

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/clojure/cljs/analyzer.cljc

+4-3
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@
109109
(str "Use of undeclared Var " (:prefix info) "/" (:suffix info)))
110110

111111
(defmethod error-message :undeclared-ns
112-
[warning-type {:keys [ns-sym] :as info}]
112+
[warning-type {:keys [ns-sym js-provide] :as info}]
113113
(str "No such namespace: " ns-sym
114114
", could not locate " (util/ns->relpath ns-sym :cljs)
115-
" or " (util/ns->relpath ns-sym :cljc)))
115+
", " (util/ns->relpath ns-sym :cljc)
116+
", or Closure namespace \"" js-provide "\""))
116117

117118
(defmethod error-message :dynamic
118119
[warning-type info]
@@ -1290,7 +1291,7 @@
12901291
(analyze-file src opts)
12911292
(throw
12921293
(error env
1293-
(error-message :undeclared-ns {:ns-sym dep}))))))))))
1294+
(error-message :undeclared-ns {:ns-sym dep :js-provide (name dep)}))))))))))
12941295

12951296
(defn check-uses [uses env]
12961297
(doseq [[sym lib] uses]

src/main/clojure/cljs/closure.clj

+4-2
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,13 @@
518518
(let [relpath (str path ".cljc")]
519519
(if-let [cljc-res (io/resource relpath)]
520520
{:relative-path relpath :uri cljc-res}
521-
(let [relpath (:file (get-in @compiler-env [:js-dependency-index (str ns)]))]
521+
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
522+
relpath (or (:file ijs) (:url ijs))]
522523
(if-let [js-res (and relpath
523524
;; try to parse URL, otherwise just return local
524525
;; resource
525-
(or (try (URL. relpath) (catch Throwable t))
526+
(or (and (util/url? relpath) relpath)
527+
(try (URL. relpath) (catch Throwable t))
526528
(io/resource relpath)))]
527529
{:relative-path relpath :uri js-res}
528530
(throw

0 commit comments

Comments
 (0)