This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-11
Channels
- # announcements (1)
- # aws (5)
- # beginners (35)
- # calva (18)
- # clerk (5)
- # clojure (20)
- # clojure-berlin (1)
- # clojure-dev (12)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (159)
- # clojure-uk (5)
- # clojurescript (8)
- # conjure (1)
- # cursive (18)
- # events (10)
- # fulcro (23)
- # hyperfiddle (5)
- # introduce-yourself (3)
- # juxt (2)
- # off-topic (1)
- # polylith (4)
- # portal (11)
- # releases (1)
- # shadow-cljs (4)
- # xtdb (9)
- # yamlscript (1)
I'm trying to get a macro to compile differently based on the environment (dev vs prod) it's being built as, and I'm not quite sure how I should go about that - currently I'm got a config
namespace with ENVIRONMENT
that I override in the closure-defines
in shadow-cljs.edn, but the config
namespace for the clojure side of things (obviously) doesn't get set at compile time.
For example, the current code evaluates to:
(defmacro environment []
`{:local config/ENVIRONMENT :compile ~config/ENVIRONMENT})
{:local "dev" :compile :dev}
because in the config.clj
I have (def ENVIRONMENT :dev)
and in config.cljs
I have (goog-define ENVIRONMENT "dev")
(this is needed because of some fickle api policy code that needs to inline for performance reasons at build time, but breaks because of being a macro at dev time during hot reloads)
I need to be able to have the above macro yield:
{:local "dev" :compile "dev"}
at dev time time and {:local "prod" :compile "prod"}
when I'm building a release version.. any pointers?I'm working around this for now by using export ENV=dev/prod
in the build scripts, #shadow/env "ENV"
in the shadow-cljs.edn, and (*def* ENVIRONMENT (System/getenv "ENV"))
in the config.clj.. would have preferred being able to access the build environment of shadow-cljs (being able to distinguish between watch
vs release
at compile time would be neat)