This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-16
Channels
- # admin-announcements (11)
- # arachne (4)
- # beginners (7)
- # boot (21)
- # clojure (41)
- # clojure-greece (2)
- # clojure-japan (7)
- # clojure-poland (4)
- # clojure-russia (25)
- # clojure-sg (1)
- # clojure-uk (3)
- # clojurescript (23)
- # cursive (2)
- # datomic (2)
- # devcards (2)
- # euroclojure (6)
- # hoplon (101)
- # immutant (4)
- # leiningen (4)
- # mount (8)
- # off-topic (2)
- # om (34)
- # onyx (2)
- # planck (1)
- # re-frame (4)
- # reagent (16)
- # spacemacs (6)
- # untangled (19)
is there a way to check the compilation mode in the clojurescript file?
@sbondaryev: not by default I believe but you can use :closure-defines
for this kind of stuff
allows you to pass constants into the code during compile time
@sbondaryev: alternatively you can use environmental variables and use macros to “expose” them to clojurescript code (something like this): https://github.com/binaryage/chromex/blob/master/src/lib/chromex/config.clj#L7-L14
and then use macro to generate compile-time map for cljs: https://github.com/binaryage/chromex/blob/master/src/lib/chromex/config.clj#L56
it is a bit more involved, but you don’t have to rely on :closure-defines, which has its own quirks
Ok thanks, I’ll consider this solutions
I prepare a lib - their code depends on compilation mode
I see your point, I’m not aware of any existing solution, you have to ask user of your library to specify env var to indicate compilation mode for your lib
the problem is that you would in general case want complete compiler configuration available somewhere (in env vars for my solution)
this env-var solution is not that bad IMO, both leiningen and boot offer plugins to do that from project.clj or by other means
this is what chromex-sample does for release build: https://github.com/binaryage/chromex-sample/blob/master/project.clj#L78
actually I ran into issues with this solution when using lein profiles, but that is another story: https://github.com/weavejester/environ/pull/53
I’m probably going to write my own lein-environ plugin, maybe we could think about a way how to expose complete cljs compiler environment there, but I assume you want a generic solution not dependent on build infrastructure used
Thanks, i'll look into it
or we could try to implement a patch of cljs compiler, which would expose compiler config to macros (in clojure)
that would the best solution, but I’m not sure if would potentially have chance to be accepted