Skip to content

Commit

Permalink
don't use the cljs namespace parser on cli files
Browse files Browse the repository at this point in the history
it does extra work and fails on single segment namespaces
  • Loading branch information
Bruce Hauman committed Aug 8, 2018
1 parent 207f645 commit 57f6171
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/figwheel/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
[clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.edn :as edn]
[clojure.tools.reader :as redr]
[clojure.tools.reader.edn :as redn]
[clojure.tools.reader.reader-types :as rtypes]
[figwheel.tools.exceptions :as fig-ex]]))
#?(:cljs (:require-macros [figwheel.core]))
(:import #?@(:cljs [[goog]
Expand Down Expand Up @@ -455,10 +458,30 @@
(files source-file))
(js-dependencies-with-file-urls js-dependency-index)))))

(defn read-clj-forms [eof file]
(let [reader (rtypes/source-logging-push-back-reader (io/reader file))]
(repeatedly
#(try
(redr/read {:read-cond :allow :features #{:clj} :eof eof} reader)
(catch Throwable t
eof)))))

(defn parse-clj-ns [file]
(let [eof (Object.)
res (first
(filter #(or
(= eof %)
(and (list? %)
(= (first %) 'ns)))
(read-forms eof file)))]
(when (not= res eof)
(second res))))

(defn clj-paths->namespaces [paths]
(->> paths
(filter #(.exists (io/file %)))
(map (comp :ns ana/parse-ns io/file))
(map io/file)
(filter #(.isFile %))
(keep parse-clj-ns)
distinct))

(defn figwheel-always-namespaces [figwheel-ns-meta]
Expand Down

0 comments on commit 57f6171

Please sign in to comment.