Skip to content

Commit

Permalink
CLJS-1168: REPL fails to find .js files in :libs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
swannodette committed May 9, 2015
1 parent 159fad2 commit 5858966
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main/clojure/cljs/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@
(str "Use of undeclared Var " (:prefix info) "/" (:suffix info)))

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

(defmethod error-message :dynamic
[warning-type info]
Expand Down Expand Up @@ -1290,7 +1291,7 @@
(analyze-file src opts)
(throw
(error env
(error-message :undeclared-ns {:ns-sym dep}))))))))))
(error-message :undeclared-ns {:ns-sym dep :js-provide (name dep)}))))))))))

(defn check-uses [uses env]
(doseq [[sym lib] uses]
Expand Down
6 changes: 4 additions & 2 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,13 @@
(let [relpath (str path ".cljc")]
(if-let [cljc-res (io/resource relpath)]
{:relative-path relpath :uri cljc-res}
(let [relpath (:file (get-in @compiler-env [:js-dependency-index (str ns)]))]
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
relpath (or (:file ijs) (:url ijs))]
(if-let [js-res (and relpath
;; try to parse URL, otherwise just return local
;; resource
(or (try (URL. relpath) (catch Throwable t))
(or (and (util/url? relpath) relpath)
(try (URL. relpath) (catch Throwable t))
(io/resource relpath)))]
{:relative-path relpath :uri js-res}
(throw
Expand Down

0 comments on commit 5858966

Please sign in to comment.