bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 210 forks source link

Support :closure-defines #675

Closed mfikes closed 6 years ago

mfikes commented 6 years ago

Desired feature: If the :closure-defines compiler option is set, then, upon setup (or perhaps first eval for a given environment where not yet set) Figwheel should set js/goog.global.CLOSURE_UNCOMPILED_DEFINES with a JavaScript object formed from the supplied map so that goog-define works.

Here is an example of working around this directly in the Figwheel REPL, just to illustrate how the feature works:

ios:cljs.user=> (set! js/goog.global.CLOSURE_UNCOMPILED_DEFINES #js {"foo.core.bar" 11})
#js {"foo.core.bar" 11}
ios:cljs.user=> (ns foo.core)

ios:foo.core=> (goog-define bar 10)
nil
ios:foo.core=> bar
11

Here are examples of how this is implemented in the base REPLs that ship with ClojureScript:

Node, Browser, Nashorn

mfikes commented 6 years ago

I've tested this in a project crated using lein new figwheel hello-world and it works. This is actually not an issue with Figwheel, but in downstream re-natal: https://github.com/drapanjanas/re-natal/issues/46