Fork me on GitHub
#clojurescript
<
2018-04-02
>
danielstockton09:04:16

How does cljs know to remove (if js.goog.DEBUG) from prod builds? Is there something in the compiler that recognises js.goog.DEBUG as the single test condition?

Roman Liutikov09:04:04

It’s not cljs, but Closure Compiler (the one that optimizes JavaScript output)

rauh09:04:13

Also: Use goog/DEBUG instead of js.goog.DEBUG

Roman Liutikov09:04:27

With a type hint ^boolean goog.DEBUG Closure can infer the value. If it’s false, then the whole branch can be removed

danielstockton09:04:42

Ok, so I need a type hint. I guess I meant, how does the compiler know that this can be evaluated at compile time rather than being a runtime condition.

danielstockton09:04:11

So (def debug? ^boolean goog/DEBUG) and (when-not debug?) would be removed from the build?

thheller09:04:28

@U0DHDNZR9 goog.DEBUG is controlled via :closure-defines which are basically compile time constants. so they get substituted by their value when optimizing.

👍 4
danielstockton09:04:24

Got it, so basically it becomes (if false) and the closure compiler knows that it will never need that branch.

danielstockton09:04:43

Type hint is probably not necessary for this to occur, am i right?

thheller09:04:38

typehint is required because CLJS will emit if (cljs.core.thruth_(something)) which closure doesn't recognize

thheller09:04:52

with boolean hint its just if (something)

rgm17:04:22

is there a dominant technique for asset fingerprinting/far-future expiry with cljs builds? I'm having that fun experience of explaining how to do a hard-reload to some beta testers.

rgm17:04:54

(or is there some other practice for making sure the latest compiled bundle is working?)

thheller17:04:30

shadow-cljs has :module-hash-names if you are talking about fingerprinting the JS itself. see https://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing

thheller17:04:46

no idea what others are doing

rgm17:04:08

Oh thanks. I’ll have a look at that. Sadly this isn’t the project I’m flipping over to shadow (yet) but getting ideas is very helpful.

rgm17:04:27

Thinking I could manually MD5 in a ring handler and just re-write the bundle <script> tag on the outbound index.html to add the suffix. Feels dirty, but workable.

justinlee17:04:33

has anyone had any success in getting the clog / clogn macros to work in a browser-based clojurescript application from https://github.com/philoskim/debux

justinlee17:04:50

they just don’t print anything for me

thheller17:04:27

@lee.justin.m it appears that it is doing a lot of cache-hostile macro trickery. you might need to block or turn off caching for this. see https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache

justinlee19:04:33

@U05224H0W thanks, but there’s something more profoundly wrong about this. (clog "thing") is supposed to print “thing” and return thing, but it actually prints nothing and returns (debux.cs.clog/clog nil {:evals (atom {})})

kah0ona18:04:48

I do see an added node_modules dir with uppy and deps in it. So I kind of feel i’m nearly there.

zaphodious19:04:31

Just published the alpha for my service worker library. Thoughts? Feelings? Input in general would be appreciated 🙂

robert-stuttaford19:04:50

neat! what are you using it for @achythlook?

zaphodious19:04:05

I'm building a webapp, and wanted to use service workers. My initial experience was absolutely dreadful, and I couldn't find any cljs libraries to help. Welp, I suppose its up to me 🙂

zaphodious19:04:27

I'm going to use it, along with an app manifest, to make my webapp as close to native as I can 🙂

zaphodious19:04:44

The incredible promise of service workers is that they can make our webapps faster and more accessible then native apps, including being available offline with much of the same functionality.

zaphodious19:04:13

Given how important this tech is, I'm really concerned about doing this stuff correctly. The clojure community seems to stick to libraries that exist if they work well enough, so this library might be used widely and exclusively. I don't want to introduce any bad practices :S

andnils19:04:36

How do you handle 3rd party css files in cljs? Example, I use the c3 chart lib (via cljsjs.c3). Do you copy the c3 css file to your resource-dir, or use a CDN, or is there another way to do it?

andnils19:04:03

Great! Didn’t know about that. Thanks a bunch!

robert-stuttaford20:04:43

ah, the page references this lib 🙂

Ykä20:04:15

I've been learning ClojureScript and Reagent during easter. Everything has worked very smoothly. It has been even more positive experience than when I tried them out last time (2,5 years ago). Big 👍 for all people working on Clojure, ClojureScript, Figwheel, Reagent, Doo etc!

👍 8
robert-stuttaford20:04:27

amen to that @yka. i’ve used Rum for the last 3 years (which is totally fine) - decided to try re-frame + 10x out this weekend. had a blast. https://github.com/robert-stuttaford/bridge/

4
danielglauser22:04:29

re-frame is our weapon of choice. I’ve got a side project where I’m trying to see if I can use re-com for general purpose app development. Slightly stuck in a drag-n-drop rabbit hole.

benzap14:04:47

How would you compare it to rum? I've been using only rum, and i've only ever really tried it along with om.

danielglauser22:04:45

Sorry I missed this. Haven’t used rum so I’m not a good person to make a comparison.

robert-stuttaford10:04:42

@U0670BDCH rum is comparable with reagent. re-frame adds a state management and data flow coordination layer on top.

👍 8
benzap19:04:01

oh that's helpful, I should check it out then

danielglauser19:04:34

I did a bunch of Om work then moved to re-frame. It felt like re-frame addressed a lot of the missing pieces around how I should structure the front end of my app.