|
2191 | 2191 | (assert (not (and (= target :nodejs) (= optimizations :none) (not (contains? opts :main)))) |
2192 | 2192 | (format ":nodejs target with :none optimizations requires a :main entry"))) |
2193 | 2193 |
|
| 2194 | +(defn check-main [{:keys [main] :as opts}] |
| 2195 | + (when main |
| 2196 | + (assert (symbol? main) |
| 2197 | + (format ":main must be a symbol, got %s instead" main)) |
| 2198 | + (assert (not (string/starts-with? (str main) "'")) |
| 2199 | + (format ":main must be an unquoted symbol, got %s instead" main)))) |
| 2200 | + |
2194 | 2201 | (defn check-preloads [{:keys [preloads optimizations] :as opts}] |
2195 | 2202 | (when (and (some? preloads) |
2196 | 2203 | (not= preloads '[process.env]) |
|
2812 | 2819 | [ns opts] |
2813 | 2820 | (compile-inputs (find-sources ns opts) opts)) |
2814 | 2821 |
|
| 2822 | +(defn validate-opts [opts] |
| 2823 | + (check-output-to opts) |
| 2824 | + (check-output-dir opts) |
| 2825 | + (check-source-map opts) |
| 2826 | + (check-source-map-path opts) |
| 2827 | + (check-output-wrapper opts) |
| 2828 | + (check-node-target opts) |
| 2829 | + (check-preloads opts) |
| 2830 | + (check-cache-analysis-format opts) |
| 2831 | + (check-main opts) |
| 2832 | + opts) |
| 2833 | + |
2815 | 2834 | (defn build |
2816 | 2835 | "Given compiler options, produce runnable JavaScript. An optional source |
2817 | 2836 | parameter may be provided." |
|
2848 | 2867 | ana/*cljs-static-fns*) |
2849 | 2868 | sources (when source |
2850 | 2869 | (-find-sources source opts))] |
2851 | | - (check-output-to opts) |
2852 | | - (check-output-dir opts) |
2853 | | - (check-source-map opts) |
2854 | | - (check-source-map-path opts) |
2855 | | - (check-output-wrapper opts) |
2856 | | - (check-node-target opts) |
2857 | | - (check-preloads opts) |
2858 | | - (check-cache-analysis-format opts) |
| 2870 | + (validate-opts opts) |
2859 | 2871 | (swap! compiler-env |
2860 | 2872 | #(-> % |
2861 | 2873 | (update-in [:options] merge opts) |
|
0 commit comments