   the default externs should be excluded."
   [{:keys [externs use-only-custom-externs target]}]
   (letfn [(filter-js [paths]
-            (for [p paths f (file-seq (io/file p))
-                  :when (.endsWith (.toLowerCase (.getName f)) ".js")]
-              (.getAbsolutePath f)))
+            (for [p paths u (find-js-resources p)] u))
           (add-target [ext]
             (if (= :nodejs target)
-              (cons (.getFile (io/resource "cljs/nodejs_externs.js"))
+              (cons (io/resource "cljs/nodejs_externs.js")
                     (or ext []))
               ext))
           (load-js [ext]
-            (map #(js-source-file % (io/input-stream %)) ext))]
+            (map #(js-source-file (.getFile %) (slurp %)) ext))]
     (let [js-sources (-> externs filter-js add-target load-js)]
       (if use-only-custom-externs
         js-sources

        (set-options opts compiler-options)
        compiler-options)))

(defn load-externs
  "Externs are JavaScript files which contain empty definitions of
  functions which will be provided by the envorinment. Any function in

  containing Javascript files, return a list of maps
  containing :provides, :requires, :file and :url."
  [path]
  (letfn [(graph-node [u]
            (-> (io/reader u)
                line-seq
                parse-js-ns
                (assoc :url u)))]
    (let [js-sources (find-js-resources path)]
      (filter #(seq (:provides %)) (map graph-node js-sources)))))

(def load-library (memoize load-library*))
