|
135 | 135 | using a supplied read-file-fn, calling back upon first successful |
136 | 136 | read, otherwise calling back with nil. Before calling back, first |
137 | 137 | attempts to read AOT artifacts (JavaScript and cache edn)." |
138 | | - [[filename & more-filenames] read-file-fn cb] |
| 138 | + [[filename & more-filenames] macros read-file-fn cb] |
139 | 139 | (if filename |
140 | 140 | (read-file-fn |
141 | 141 | filename |
|
144 | 144 | (let [source-cb-value {:lang (filename->lang filename) |
145 | 145 | :file filename |
146 | 146 | :source source}] |
147 | | - (if (or (string/ends-with? filename ".cljs") |
148 | | - (string/ends-with? filename ".cljc")) |
| 147 | + (if (and (not macros) |
| 148 | + (or (string/ends-with? filename ".cljs") |
| 149 | + (string/ends-with? filename ".cljc"))) |
149 | 150 | (read-file-fn |
150 | 151 | (replace-extension filename ".js") |
151 | 152 | (fn [javascript-source] |
|
160 | 161 | (cb source-cb-value)))) |
161 | 162 | (cb source-cb-value)))) |
162 | 163 | (cb source-cb-value))) |
163 | | - (read-some more-filenames read-file-fn cb)))) |
| 164 | + (read-some more-filenames macros read-file-fn cb)))) |
164 | 165 | (cb nil))) |
165 | 166 |
|
166 | 167 | (defn filenames-to-try |
|
192 | 193 | 'cljs.tools.reader |
193 | 194 | 'clojure.walk}) name)) |
194 | 195 |
|
195 | | -;; An atom to keep track of things we've already loaded |
196 | | -(def loaded (atom #{})) |
197 | | - |
198 | | -(defn load? |
199 | | - "Determines whether the given namespace should be loaded." |
200 | | - [name macros] |
201 | | - (let [do-not-load (or (@loaded [name macros]) |
202 | | - (skip-load? name macros))] |
203 | | - (swap! loaded conj [name macros]) |
204 | | - (not do-not-load))) |
205 | | - |
206 | 196 | (defn make-load-fn |
207 | 197 | "Makes a load function that will read from a sequence of src-paths |
208 | 198 | using a supplied read-file-fn. It returns a cljs.js-compatible |
|
212 | 202 | with the source of the library (as string)." |
213 | 203 | [src-paths read-file-fn] |
214 | 204 | (fn [{:keys [name macros path]} cb] |
215 | | - (if (load? name macros) |
| 205 | + (if-not (skip-load? name macros) |
216 | 206 | (if (re-matches #"^goog/.*" path) |
217 | 207 | (load-goog name cb) |
218 | | - (read-some (filenames-to-try src-paths macros path) read-file-fn cb)) |
| 208 | + (read-some (filenames-to-try src-paths macros path) macros read-file-fn cb)) |
219 | 209 | (cb {:source "" |
220 | 210 | :lang :js})))) |
221 | 211 |
|
|
0 commit comments