Skip to content

Commit e5db811

Browse files
committed
REPL support for Closure libraries that follow classpath conventions
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
1 parent ef0a905 commit e5db811

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main/clojure/cljs/closure.clj

+12-9
Original file line numberDiff line numberDiff line change
@@ -518,18 +518,21 @@
518518
(let [relpath (str path ".cljc")]
519519
(if-let [cljc-res (io/resource relpath)]
520520
{:relative-path relpath :uri cljc-res}
521-
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
522-
relpath (or (:file ijs) (:url ijs))]
523-
(if-let [js-res (and relpath
521+
(let [relpath (str path ".js")]
522+
(if-let [js-res (io/resource relpath)]
523+
{:relative-path relpath :uri js-res}
524+
(let [ijs (get-in @compiler-env [:js-dependency-index (str ns)])
525+
relpath (or (:file ijs) (:url ijs))]
526+
(if-let [js-res (and relpath
524527
;; try to parse URL, otherwise just return local
525528
;; resource
526529
(or (and (util/url? relpath) relpath)
527-
(try (URL. relpath) (catch Throwable t))
528-
(io/resource relpath)))]
529-
{:relative-path relpath :uri js-res}
530-
(throw
531-
(IllegalArgumentException.
532-
(str "Namespace " ns " does not exist"))))))))))
530+
(try (URL. relpath) (catch Throwable t))
531+
(io/resource relpath)))]
532+
{:relative-path relpath :uri js-res}
533+
(throw
534+
(IllegalArgumentException.
535+
(str "Namespace " ns " does not exist"))))))))))))
533536

534537
(defn cljs-dependencies
535538
"Given a list of all required namespaces, return a list of

0 commit comments

Comments
 (0)