Clojurians
#cljs-dev
<
2017-04-12
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

bronsa08:04:02

:raised_hands:

dnolen14:04:21

@anmonteiro finally :slightly_smiling_face: I’ll cut a release just for this probably later today

thheller14:04:30

@darwin the problem is that Closure doesn't really understand the CLJS immutable collections. so at some point it will give up optimizing them

thheller14:04:28

that is not a problem in most cases though

darwin14:04:19

@thheller ok, thanks for your input

darwin14:04:49

I’m probably going to leave that issue open, maybe will play with an alternative implementation of cljs.core.PersistentHashMap.fromArrays just out of curiosity. once, I was able to reimplement a core method to be less dynamic and understood by DCE: https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/prefs.cljs#L5-L7

thheller14:04:11

I'm sure a ticket that optimizes cljs.pprint in terms of DCE will be considered

darwin14:04:49

unfortunately multi-method api is the deal breaker here, I guess

darwin14:04:46

@thheller I’m going to fix all my code to use lazy config maps initializations - like you proposed. And then use macros to generate my ns-forms. Will check compiler options and in advanced mode I won’t require cljs.pprint. In my code I will dynamically check for its presence and use non-formatted code path. Something along those lines.

favila14:04:14

anyone have any experience with writing closure compiler plugins? I saw someone wrote one for react components http://blog.persistent.info/2015/05/teaching-closure-compiler-about-react.html and ever since I have wondered about the possibilities of teaching Closure more about generated cljs

thheller14:04:15

@darwin seems to me you are trying to optimize something the user really needs to take care of? just make :preloads the only safe recommended path

thheller14:04:34

everything else doesn't matter then

favila14:04:09

I was thinking in terms of performance (maybe lowering maps down to struct js objects), but perhaps DCE would be easier and more fruitful

favila14:04:34

maybe some defmethods could be eliminated, for eg

thheller14:04:25

you could maybe write a pass that removed the entire defmulti if it is never called anywhere but I think that would be hard

favila14:04:41

interesting, thanks for these links

thheller14:04:49

wrote another pass recently to remove (def x (some-side-effecting-fn)) where closure would strip the def but leave the (some-side-effecting-fn) which produces something that isn't useable without the result

favila14:04:56

I saw that one

thheller14:04:37

that one I'm still messing with but it works

favila14:04:38

how do you determine result is necessary for use?

thheller14:04:44

you give it a #{"my.super.side_effect_fn"} set and if it finds calls to that fn that aren't assigned to anything it will remove it

thheller15:04:00

this relies on a previous closure pass that removes the vars if they aren't used

favila15:04:09

the callsToRemove is via a compiler option?

thheller15:04:40

no, you need to register the whole thing as a compiler pass

thheller15:04:32

(cljs/add-closure-configurator
              (fn [cc co]
                (RemoveNameDependentCalls/install cc co #{"my.foo.fn"})
                ))

thheller15:04:11

that is with shadow-build, not sure how you can get to that in cljs normally

favila15:04:21

oh, you instantiate, not the compiiler

favila15:04:58

ok, thanks

favila15:04:26

other than https://github.com/google/closure-compiler/wiki/Writing-Compiler-Pass and other people's sample code I've never found any documentation

favila15:04:46

I guess you just have to read lots of java

thheller15:04:48

yeah requires digging to the code pretty much

thheller15:04:56

some things are even package protected

thheller15:04:22

which is why my stuff is in com.google.javascript.jscomp and not my own package

favila15:04:30

adding to CompilerOptions is still better than what the wiki talks about (editing DefaultPassConfig.java)

favila15:04:49

ah, I was wondering about that

thheller15:04:21

I do think that the protected function I was using back then is public nowadays

thheller15:04:36

didn't bother checking, but yeah the wiki should really mention addCustomPass

thheller15:04:50

expecting to build closure entirely is crazy talk

thheller15:04:13

well depends on when you need your pass to run, if specifically need to be in between two things

thheller15:04:26

those worked for my purposes

favila15:04:18

thanks for the pointers

anmonteiro18:04:57

@dnolen FWIW we’ve been using the new compiler release since yesterday in Prod

anmonteiro18:04:11

in case you needed a sanity check

dnolen18:04:03

@anmonteiro cool, yeah will cut a release later today