Browser-REPL automation & usability enhancements


  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:


The current implementation of browser-REPL yields a number of usability problems:

  • only one browser-REPL can be used at a time due to globals used to track REPL state
  • Browser-REPL currently involves two web servers: the one you're serving your app from, and the one that the REPL itself uses
    • This makes setup difficult in the interactive case — especially for newcomers, the less experienced, or the tired
    • Perhaps more significantly, coordinating the two servers and their associated state is less than easy if one wants to automate the browser-REPL for testing of DOM-related cljs code

Attached is a patch that addresses these issues:

  • Multiple concurrent browser-REPLs can be safely used
  • The browser-REPL's HTTP server is now always-on
  • Replaced the custom HTTP server with* bits, which are a part of J2SE 6+, not random implementation details
  • Each browser-REPL session supports a new top-level "entry" URL that can be used to easily start the REPL in a browser or other JS runtime (i.e. you don't need to have a separate webapp running to initiate the browser-REPL connection)
  • The entry (and REPL) URLs are available in slots on the browser-REPL's environment, making it trivial to automate browser-REPL sessions with e.g. phantomjs or a headless chromium or etc. This pattern is implemented by a new `exec-env` function; the default is to start the REPL in phantomjs using a temporary script, but it's super-easy to use a regular browser. e.g. this will use Chrome on OS X in the background:
(cljs.repl/repl (cljs.repl.browser/exec-env
                  :exec-cmds ["open" "-ga" "/Applications/Google"]))

(This enhancement has been discussed previously {here|}.)


Chas Emerick made changes -
Field Original Value New Value
Attachment CLJS-489.diff [ 11925 ]
Patch Code [ 10001 ]
Chas Emerick made changes -
Attachment CLJS-489.diff [ 11925 ]
Chas Emerick made changes -
Attachment CLJS-489.diff [ 12031 ]
Chas Emerick made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Declined [ 2 ]


Vote (2)
Watch (4)


  • Created: