<< Back to previous view

[CLJS-521] Pass along compiler options added to REPL environments Created: 16/Jun/13  Updated: 28/Oct/13  Resolved: 28/Oct/13

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Chas Emerick Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: File CLJS-521.diff    
Patch: Code


Many of the compiler options (esp. :libs, :externs, etc.) that are accepted by the compiler (and commonly specified via lein-cljsbuild options) should also apply to ClojureScript REPL sessions. Since all known IJavaScriptEnv implementations are records, the most straightforward way to do this is to allow one to add such options to REPL environment records, which can then be passed on to the compiler in cljs.repl.

Making this change has had a big impact on my personal ClojureScript productivity. Interested in the patch?

Comment by David Nolen [ 17/Jun/13 12:23 PM ]

Patch welcome!

Comment by Chas Emerick [ 17/Jun/13 1:44 PM ]

Awesome; will put one up once the disposition of CLJS-489 is settled, since the browser-repl impl details are obviously implicated somewhat.

Comment by Chas Emerick [ 21/Oct/13 2:38 PM ]

AFAICT, the only options where this makes sense are :libs and :foreign-libs. These two are needed to allow you to have dependencies loaded as they would be using e.g. lein-cljsbuild. The rest of the ClojureScript compiler options are of relatively minimal use in the REPL.

This conveniently keeps the scope of the change down, affecting only the dependency-loading bits in cljs.repl.

I'll update the relevant wiki page to reflect this change once this is applied.

Comment by Chas Emerick [ 28/Oct/13 7:35 AM ]

FYI, the attached patch applies cleanly on master after the latest release and still works as expected.

Comment by David Nolen [ 28/Oct/13 8:41 AM ]

I don't understand why you are using :simple optimizations here. Can you explain?

Comment by Chas Emerick [ 28/Oct/13 8:58 AM ]

That's only the default used if the REPL environment doesn't specify one, and if the REPL environment uses Closure optimization to begin with. The only stock REPL environment that does any optimization is the browser REPL, which defaults to :simple; without anything else to go on, it seemed reasonable to copy it.

The only alternative would be :whitespace. I have no objection to defaulting to that, but I don't see any practical difference between the two given the REPL context.

Comment by David Nolen [ 28/Oct/13 11:18 AM ]

Yes but I don't understand why :none is not applicable here - any explanation?

Comment by Chas Emerick [ 28/Oct/13 11:40 AM ]

OK, I had no idea :none was even an option; found where it comes into play just now when I grepped cljs.closure. (I saw the case in cljs.closure/make-options, and worked from there.) I'll redo the patch with :none, test with some downstream REPL envs to make sure everything works as expected, and re-attach.

Comment by Chas Emerick [ 28/Oct/13 11:46 AM ]

Updated patch attached that defaults :optimizations to :none. Works fine in tests with downstream REPL envs, etc.

Comment by David Nolen [ 28/Oct/13 5:36 PM ]

fixed, http://github.com/clojure/clojurescript/commit/d03c15bb10b1496660d59f8092617b02f9cada8a

Generated at Fri Sep 22 15:41:27 CDT 2017 using JIRA 4.4#649-r158309.