|
253 | 253 | (cljsc/js-dependencies opts cljs))] |
254 | 254 | (disj (set (concat cljs goog)) nil))) |
255 | 255 |
|
256 | | -(defn repl-env |
257 | | - "Create a browser-connected REPL environment. |
258 | | -
|
259 | | - Options: |
| 256 | +;; NOTE: REPL evaluation environment designers do not replicate the behavior |
| 257 | +;; of the browser REPL. The design is outdated, refer to the Node.js, Rhino or |
| 258 | +;; Nashorn REPLs. |
260 | 259 |
|
261 | | - port: The port on which the REPL server will run. Defaults to 9000. |
262 | | - working-dir: The directory where the compiled REPL client JavaScript will |
263 | | - be stored. Defaults to \".repl\" with a ClojureScript version |
264 | | - suffix, eg. \".repl-0.0-2138\". |
265 | | - serve-static: Should the REPL server attempt to serve static content? |
266 | | - Defaults to true. |
267 | | - static-dir: List of directories to search for static content. Defaults to |
268 | | - [\".\" \"out/\"]. |
269 | | - preloaded-libs: List of namespaces that should not be sent from the REPL server |
270 | | - to the browser. This may be required if the browser is already |
271 | | - loading code and reloading it would cause a problem. |
272 | | - optimizations: The level of optimization to use when compiling the client |
273 | | - end of the REPL. Defaults to :simple. |
274 | | - src: The source directory containing user-defined cljs files. Used to |
275 | | - support reflection. Defaults to \"src/\". |
276 | | - " |
277 | | - [& {:as opts}] |
278 | | - (let [ups-deps (cljsc/get-upstream-deps (java.lang.ClassLoader/getSystemClassLoader)) |
| 260 | +(defn repl-env* [opts] |
| 261 | + (let [ups-deps (cljsc/get-upstream-deps) |
279 | 262 | opts (assoc opts |
280 | 263 | :ups-libs (:libs ups-deps) |
281 | 264 | :ups-foreign-libs (:foreign-libs ups-deps)) |
|
284 | 267 | {:port 9000 |
285 | 268 | :optimizations :simple |
286 | 269 | :working-dir (or (:output-dir opts) |
287 | | - (->> [".repl" (util/clojurescript-version)] |
288 | | - (remove empty?) (string/join "-"))) |
| 270 | + (->> [".repl" (util/clojurescript-version)] |
| 271 | + (remove empty?) (string/join "-"))) |
289 | 272 | :serve-static true |
290 | 273 | :static-dir (cond-> ["." "out/"] |
291 | 274 | (:output-dir opts) (conj (:output-dir opts))) |
|
304 | 287 | (swap! browser-state |
305 | 288 | (fn [old] |
306 | 289 | (assoc old :client-js |
307 | | - (create-client-js-file |
308 | | - opts |
309 | | - (io/file (:working-dir opts) "client.js"))))) |
| 290 | + (create-client-js-file |
| 291 | + opts |
| 292 | + (io/file (:working-dir opts) "client.js"))))) |
310 | 293 | (println "Waiting for browser to connect ...") |
311 | 294 | opts))) |
312 | 295 |
|
| 296 | +(defn repl-env |
| 297 | + "Create a browser-connected REPL environment. |
| 298 | +
|
| 299 | + Options: |
| 300 | +
|
| 301 | + port: The port on which the REPL server will run. Defaults to 9000. |
| 302 | + working-dir: The directory where the compiled REPL client JavaScript will |
| 303 | + be stored. Defaults to \".repl\" with a ClojureScript version |
| 304 | + suffix, eg. \".repl-0.0-2138\". |
| 305 | + serve-static: Should the REPL server attempt to serve static content? |
| 306 | + Defaults to true. |
| 307 | + static-dir: List of directories to search for static content. Defaults to |
| 308 | + [\".\" \"out/\"]. |
| 309 | + preloaded-libs: List of namespaces that should not be sent from the REPL server |
| 310 | + to the browser. This may be required if the browser is already |
| 311 | + loading code and reloading it would cause a problem. |
| 312 | + optimizations: The level of optimization to use when compiling the client |
| 313 | + end of the REPL. Defaults to :simple. |
| 314 | + src: The source directory containing user-defined cljs files. Used to |
| 315 | + support reflection. Defaults to \"src/\". |
| 316 | + " |
| 317 | + [& {:as opts}] |
| 318 | + (assert (even? (count opts)) "Arguments must be interleaved key value pairs") |
| 319 | + (repl-env* opts)) |
| 320 | + |
313 | 321 | (comment |
314 | 322 |
|
315 | 323 | (require '[cljs.repl :as repl]) |
|
0 commit comments