Fork me on GitHub
#clojurescript
<
2016-08-04
>
asolovyov09:08:10

I'm trying to get dynamic modules working for my app and I've got a few problems I'm totally unsure how to solve; is there anybody who got it running here so I can ask about your setup?

timgilbert12:08:58

Hello all, does anyone have recommendations for how to manage configuration in browser-based ClojureScript? Eg, I’m looking for something that will provide me the proper URLs for my back-end services in QA vs staging vs production environments

timgilbert12:08:06

Ideally without exposing all the URLs for all three environments in production, so something that could process stuff at compile-time, not runtime

timgilbert12:08:00

Right now I’m conditionally including one of three directories in my build-path, but it seems really hacky, especially with lein-cljsbuild

rarous13:08:13

@timgilbert: we have another script included in page with just the ENV specific configuration (JSON stored in global variable) that can be easily generated/scripted during deployment to specific environment. We are reading the content of the global variable in main entry point and then injecting it as Map where needed.

rarous13:08:14

eg:

(let [env (obj/get js/window “my-app-env")]
  (app/init (js->clj env)))

rarous13:08:29

the trick is you have the same bundle, you need to change just the env.js file

timgilbert13:08:05

Interesting, thanks. That's similar to the approach I'm taking right now

timgilbert13:08:38

It would be nice to be able to use some kind of library or something for it though, and not have to break out of Clojure to do it

darwin16:08:30

@timgilbert: I used to use environ library to configure my code, recently I’ve learnt another technique, how to read configuration directly via cljs compiler’s config: https://github.com/binaryage/cljs-devtools/blob/9c2eda4f289761d88d61d0088a167bae594b4b0c/src/lib/devtools/preload.clj#L3

darwin16:08:01

when you have config accessible from clojure, you can decide to expose some of it to your clojuescript code via a macro

bsima16:08:40

@timgilbert: adzerk's env is a nice and simple solution https://github.com/adzerk-oss/env

shaun-mahood19:08:30

@darwin: I've got some software that has a built-in version of Chromium that I'm going to be developing against, and as far as I can tell it doesn't have the option to enable custom formatters in it's devtools menus so I can't use cljs-devtools with it. Is there anything in cljs-devtools that will work without enabling custom formatters?

darwin19:08:39

@shaun-mahood: what is the version of Chromium? or SHA

shaun-mahood19:08:23

@darwin: No idea, and no idea how to tell. Is there a command I can run at the console? I can't find any chromium executables anywhere so I'm assuming it's baked in to the product.

darwin19:08:38

are you able to type urls?

darwin19:08:53

<chrome://version/>

darwin19:08:46

anyways, if it is not exposed in embedded devtools, chances that you could make it work are slim

shaun-mahood19:08:57

Ok, version is 33.0.1750.170 (have to hardcode the URL to load it in)

darwin19:08:15

too bad, custom formatters were added around ~38

darwin19:08:36

if you are going to live with this ancient version for longer, I would recommend to invent a workflow for working against latest outside and then just port the result inside this old one

shaun-mahood19:08:02

Ok, figured that was going to be the case - thanks for the help. Pretty exciting anyway, I think I'll be able to use cljs with all the figwheel+devcards goodness where the previous workflow was <make change> -> <start debugger> -> <run program> -> <manually load dll> -> <run changed command>

darwin19:08:21

or alternatively you could implement logging as your own in-page console

darwin19:08:41

you would have to write JSON-ML renderer similar to what is implemented in DevTools console

shaun-mahood19:08:09

Yeah, I've done some in page console stuff before so I'll live with that - this is a brand new version so the very soonest there would be a chromium update would be next year.

darwin19:08:11

but the hard part of formatting cljs values in JSON-ML would be provided by cljs-devtools

shaun-mahood19:08:00

Oh that's a good idea, if I end up really needing it I'll steal your hard work.

darwin19:08:57

could be a nice afternoon exercise, to recursively walk generated JSON-ML and render it with reagent or similar library 🙂 the hardest part would be styling I guess 😉