Skip to content

Commit 9fd6bf5

Browse files
timothypratleydnolen
authored andcommitted
CLJS-869: When preamble is not found in source directory, compiler does not report it
1 parent 4fba4f1 commit 9fd6bf5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
(def -cljs-macros-loaded (atom false))
3535

3636
(def ^:dynamic *cljs-warnings*
37-
{:unprovided true
37+
{:preamble-missing true
38+
:unprovided true
3839
:undeclared-var false
3940
:undeclared-ns false
4041
:undeclared-ns-form true
@@ -60,9 +61,13 @@
6061

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

64+
(defmethod error-message :preamble-missing
65+
[warning-type info]
66+
(str "Preamble resource file not found: " (string/join " " (:missing info))))
67+
6368
(defmethod error-message :unprovided
6469
[warning-type info]
65-
(str "Required namespace not provided for " (clojure.string/join " " (:unprovided info))))
70+
(str "Required namespace not provided for " (string/join " " (:unprovided info))))
6671

6772
(defmethod error-message :undeclared-var
6873
[warning-type info]

src/clj/cljs/closure.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ should contain the source for the given namespace name."
523523
inputs)))))
524524

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

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

0 commit comments

Comments
 (0)