Skip to content

Commit

Permalink
REPL support for Closure libraries that follow classpath conventions
Browse files Browse the repository at this point in the history
cljs.closure/source-for-namespace which is used by cljs.repl/load-namespace
now checks for a js file following classpath conventions before checking the
js dependency index
  • Loading branch information
swannodette committed May 10, 2015
1 parent ef0a905 commit e5db811
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/clojure/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -518,18 +518,21 @@
(let [relpath (str path ".cljc")]
(if-let [cljc-res (io/resource relpath)]
{:relative-path relpath :uri cljc-res}
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
relpath (or (:file ijs) (:url ijs))]
(if-let [js-res (and relpath
(let [relpath (str path ".js")]
(if-let [js-res (io/resource relpath)]
{:relative-path relpath :uri js-res}
(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 (and (util/url? relpath) relpath)
(try (URL. relpath) (catch Throwable t))
(io/resource relpath)))]
{:relative-path relpath :uri js-res}
(throw
(IllegalArgumentException.
(str "Namespace " ns " does not exist"))))))))))
(try (URL. relpath) (catch Throwable t))
(io/resource relpath)))]
{:relative-path relpath :uri js-res}
(throw
(IllegalArgumentException.
(str "Namespace " ns " does not exist"))))))))))))

(defn cljs-dependencies
"Given a list of all required namespaces, return a list of
Expand Down

0 comments on commit e5db811

Please sign in to comment.