Skip to content

Commit

Permalink
CLJS-869: When preamble is not found in source directory, compiler do…
Browse files Browse the repository at this point in the history
…es not report it
  • Loading branch information
timothypratley authored and dnolen committed Oct 8, 2014
1 parent 4fba4f1 commit 9fd6bf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/clj/cljs/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
(def -cljs-macros-loaded (atom false))

(def ^:dynamic *cljs-warnings*
{:unprovided true
{:preamble-missing true
:unprovided true
:undeclared-var false
:undeclared-ns false
:undeclared-ns-form true
Expand All @@ -60,9 +61,13 @@

(defmulti error-message (fn [warning-type & _] warning-type))

(defmethod error-message :preamble-missing
[warning-type info]
(str "Preamble resource file not found: " (string/join " " (:missing info))))

(defmethod error-message :unprovided
[warning-type info]
(str "Required namespace not provided for " (clojure.string/join " " (:unprovided info))))
(str "Required namespace not provided for " (string/join " " (:unprovided info))))

(defmethod error-message :undeclared-var
[warning-type info]
Expand Down
5 changes: 4 additions & 1 deletion src/clj/cljs/closure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,10 @@ should contain the source for the given namespace name."
inputs)))))

(defn preamble-from-paths [paths]
(str (apply str (map #(slurp (io/resource %)) paths)) "\n"))
(when-let [missing (seq (remove io/resource paths))]
(ana/warning :preamble-missing @env/*compiler* {:missing (sort missing)}))
(let [resources (remove nil? (map io/resource paths))]
(str (string/join (map slurp resources)) "\n")))

(defn make-preamble [{:keys [target preamble hashbang]}]
(str (when (and (= :nodejs target) (not (false? hashbang)))
Expand Down

0 comments on commit 9fd6bf5

Please sign in to comment.