Fork me on GitHub
#clojurescript
<
2019-04-17
>
kenny00:04:12

Is there a way to def a variable in CLJS as the static result of a variable created in clj? Something like:

#?(:clj
   (def instance-types (read-aws-ec2-instance-types-from-file))
   :cljs (def instance-types ~instance-types))

kenny01:04:26

This works but seems so painful. Is there a better way?

#?(:clj
   (defmacro def-instance-types
     [sym]
     (let [instance-types (read-aws-ec2-instance-types-from-file)]
       `(def ~sym ~instance-types))))

(def-instance-types instance-types)

mfikes01:04:02

@kenny Another approach would be to make use of goog-define, and arrange to have that value set based on the contents of the file at build time. This would limit you to using a primitive value but it also avoids statically baking the value into the JavaScript emitted by the compiler (and thus is compatible with the :aot-cache feature)

mkvlr11:04:20

anybody have tips how to enable closure logging conditionally in production? I tried (goog.debug.Console/autoInstall) which doesn’t seem to suffice. Setting window.goog = {DEBUG: true} seems to break closure.

mkvlr11:04:35

oh, I guess i can set goog.DEBUG after cljs_base and before my main…

dnolen13:04:19

@mkvlr setting that via :closure-defines doesn't work?

mkvlr13:04:41

@dnolen I want to set it at runtime, not at compile time. To only enable logging when ?debug=1 is in the url.

mfikes13:04:05

I think Closure wants to elide all logging under advanced builds. Hrm.

mkvlr13:04:42

yeah, that would be another problem but currently we’re just running with :simple

mfikes13:04:57

Ahh TIL. Cool!

mkvlr13:04:07

but something else needs to happen for it to become active, trying if goog.debug.LogManager.initialize does the trick now…

clojer16:04:46

Just setup a project using JUXT Edge but connecting to a repl produces: “Error building classpath. Manifest type not detected when finding deps for juxt.edge/app.logging in coordinate #:local{:root “../edge.app.logging”}”

Alex Miller (Clojure team)16:04:44

the error is saying that it can't tell what kind of project this is (not seeing deps.edn or pom.xml - project.clj is not supported)

clojer16:04:22

Yes, looking more closely I appear not to have cusstomised my deps.edn properly.

clojer16:04:54

Thought specifying the name of the app when it was setup would have taken care of all that.

clojer16:04:51

As a lein/project.clj user I find this way more confusing. Not good for inexperienced users.

clojer17:04:56

Honestly getting a default setup to “just work” with 2 major Clojure frameworks today - Luminus and JUXT/Edge has proven futile.

clojer17:04:29

Luminus borked on some reitit middleware even though I hadn’t selected it.

clojer17:04:09

This JUXT config directory structure is so convoluted, I give up. I mean, what chance do new Clojurians have of making sense of all this. With lein there’s one config file - project.clj. Here you have an app structure which has to ../ to 16 folders all of which contain separeate deps.edn config files. I was attracted to Clojure for its simplicity, not this.

dominicm22:04:41

As mentioned, upgrade your clj version

dominicm22:04:13

Feel free to reach out to me directly if you have any more issues with Edge

dpsutton17:04:42

update your clj i believe

👍 8
dpsutton17:04:02

i think this relies on a fixed bug relating to locals/root that alex has already fixed

borkdude19:04:49

nested libspecs are not supported in CLJS?

(ns foo (:require [foo [bar]]))

borkdude19:04:15

(I personally don’t use them, just checking)

dnolen19:04:13

not supported

Alex Miller (Clojure team)19:04:30

friends don't let friends use nested libspecs

Alex Miller (Clojure team)19:04:33

and cljs is your friend

😆 16
borkdude20:04:03

I also love that CLJS doesn’t support use or refer-all

❤️ 4