|
11 | 11 |
|
12 | 12 | For example: a build script may need to how to invalidate compiled
|
13 | 13 | files so that they will be recompiled."
|
| 14 | + (:refer-clojure :exclude [compile]) |
14 | 15 | (:require [cljs.util :as util]
|
15 | 16 | [cljs.env :as env]
|
16 | 17 | [cljs.analyzer :as ana]
|
|
96 | 97 | ;; =============================================================================
|
97 | 98 | ;; Main API
|
98 | 99 |
|
| 100 | +(defn goog-dep-string |
| 101 | + "Given compiler options and a IJavaScript instance return the corresponding |
| 102 | + goog.addDependency string" |
| 103 | + [opts ijs] |
| 104 | + (closure/add-dep-string opts ijs)) |
| 105 | + |
| 106 | +(defn source-on-disk |
| 107 | + "Ensure that the given IJavaScript exists on disk in the output directory. |
| 108 | + Return updated IJavaScript with the new location if necessary." |
| 109 | + [opts ijs] |
| 110 | + (closure/source-on-disk opts ijs)) |
| 111 | + |
| 112 | +(defn ns->source |
| 113 | + "Given a namespace as a symbol return the corresponding resource if it exists." |
| 114 | + [ns] |
| 115 | + (util/ns->source ns)) |
| 116 | + |
| 117 | +(defn ns->location |
| 118 | + "Given a namespace and compilation environment return the relative path and |
| 119 | + uri of the corresponding source regardless of the source language extension: |
| 120 | + .cljs, .cljc, .js. Returns a map containing :relative-path a string, and |
| 121 | + :uri a URL." |
| 122 | + ([ns] (ns->location ns env/*compiler*)) |
| 123 | + ([ns compiler-env] |
| 124 | + (closure/source-for-namespace ns compiler-env))) |
| 125 | + |
| 126 | +(defn add-dependencies |
| 127 | + "Given one or more IJavaScript objects in dependency order, produce |
| 128 | + a new sequence of IJavaScript objects which includes the input list |
| 129 | + plus all dependencies in dependency order." |
| 130 | + [opts & ijss] |
| 131 | + (closure/add-dependencies opts ijss)) |
| 132 | + |
99 | 133 | (defn add-implicit-options
|
100 | 134 | "Given a valid map of build options add any standard implicit options. For
|
101 | 135 | example :optimizations :none implies :cache-analysis true and :source-map
|
|
120 | 154 | [compiled])))]
|
121 | 155 | (mapcat compile-input xs)))))
|
122 | 156 |
|
| 157 | +(defn compile |
| 158 | + "Given a Compilable, compile it and return an IJavaScript." |
| 159 | + [opts compilable] |
| 160 | + (closure/compile compilable opts)) |
| 161 | + |
| 162 | +(defn output-unoptimized |
| 163 | + "Ensure that all JavaScript source files are on disk (not in jars), |
| 164 | + write the goog deps file including only the libraries that are being |
| 165 | + used and write the deps file for the current project. |
| 166 | +
|
| 167 | + The deps file for the current project will include third-party |
| 168 | + libraries." |
| 169 | + [opts & sources] |
| 170 | + (apply closure/output-unoptimized opts sources)) |
| 171 | + |
123 | 172 | (defn build
|
124 | 173 | "Given a source which can be compiled, produce runnable JavaScript."
|
125 | 174 | ([source opts]
|
|
0 commit comments