dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
frank 2016-02-01T14:43:51.000204Z

is there something that can be done about this warning?

devtools/sanity_hints.js:111: WARNING - dangerous use of this in static method devtools.sanity_hints.type_error_to_string
var self = this;
           ^

Feb 01, 2016 10:36:24 PM com.google.javascript.jscomp.LoggerErrorManager printSummary

frank 2016-02-01T14:45:15.000205Z

our CI tests grep for warnings in the cljsbuild log so I can't get my build to pass šŸ˜ž

2016-02-01T14:45:32.000207Z

patch welcome, or disable sanity-hints feature in cljs-devtools

2016-02-01T14:46:11.000208Z

oh, wait maybe disabling it wonā€™t help, this is compile-time warning I guess

2016-02-01T14:47:25.000209Z

not sure if this can be rewritten somehow: https://github.com/binaryage/cljs-devtools/blob/master/src/devtools/sanity_hints.cljs#L94

frank 2016-02-01T14:50:01.000211Z

I wonder what the compiler's issue is with that

frank 2016-02-01T14:50:13.000212Z

does it have warnings whenever you use the this-as macro?

2016-02-01T14:51:11.000213Z

I think that warning is a relatively recent thing in google closure compiler, this-as could have been written/designed before

2016-02-01T14:52:38.000215Z

now I understand the issue

2016-02-01T14:53:07.000216Z

actually my code in cljs-devtools is using this-as in prototype method, but it is not obvious to closure compiler

frank 2016-02-01T14:55:49.000217Z

ah I see

frank 2016-02-01T14:55:52.000218Z

it thinks it's a static method

2016-02-01T14:57:56.000219Z

so this warning shows up only when compiling under :advanced mode?

2016-02-01T14:58:01.000220Z

Iā€™m not seeing it normally

frank 2016-02-01T14:58:10.000221Z

maybe if type-error-to-string was an anonymous function, it could get the compiler to successfully detect it as a prototype method?

2016-02-01T14:58:27.000222Z

ok, Iā€™m going to try it

frank 2016-02-01T14:58:52.000223Z

yes, this is with :advanced optimizations

2016-02-01T14:59:15.000224Z

i think you could just remove cljs-devtools from advanced build

2016-02-01T14:59:23.000225Z

it doesnā€™t work under advanced anyways

frank 2016-02-01T15:01:03.000226Z

I tried only including devtools as a dependency for my :devtools lein profile, but the code doesn't compile when I'm not using that profile

frank 2016-02-01T15:01:27.000227Z

I'm requiring it with a macro as you suggested a few days earlier

frank 2016-02-01T15:01:45.000228Z

(defmacro require-devtools! []
  (when (:devtools env)
    '(js/goog.require "frontend.devtools")))

frank 2016-02-01T15:03:09.000229Z

I think because this source file is still in my source path

frank 2016-02-01T15:03:16.000230Z

I may need to move it out

2016-02-01T15:03:24.000231Z

good, and also remove frontend/devtools folder from cljs-buildā€™s source-paths

frank 2016-02-01T15:13:06.000235Z

nice!

frank 2016-02-01T15:13:44.000236Z

thanks for helping me sort out my lein dependencies too :simple_smile:

frank 2016-02-01T15:13:53.000237Z

source paths and whatnot

2016-02-01T15:14:03.000238Z

youā€™re welcome :simple_smile:

frank 2016-02-01T15:18:17.000239Z

is there a way to set a common source path for all lein cljsbuild profiles?

frank 2016-02-01T15:19:41.000240Z

I have

:profiles {:devtools {:repl-options {:port 8230
                                       :nrepl-middleware [dirac.nrepl.middleware/dirac-repl]
                                       :init (do
                                               (require 'dirac.agent)
                                               (dirac.agent/boot!))}
                        :env {:devtools true}
                        :cljsbuild {:builds {:dev {:source-paths ["devtools"]}
                                             :whitespace {:source-paths ["devtools"]}
                                             :test {:source-paths ["devtools"]}
                                             :production {:source-paths ["devtools"]}}}
                        
                        :dependencies [[binaryage/devtools "0.5.2"]]}}

frank 2016-02-01T15:19:55.000241Z

as you can see i'm specifying :source-paths several times šŸ˜ž

2016-02-01T15:23:00.000242Z

you can use ~(<code>) to eval arbitrary <code> within leiningen project.clj

2016-02-01T15:23:40.000243Z

but that might be tricky, if some other tool reads project.clj directly

2016-02-01T15:23:52.000244Z

e.g. Cursive or maybe your own tasks

2016-02-01T15:24:38.000245Z

that being said, Iā€™m not aware of any lein-cljsbuild feature which would allow you to compose builds somehow

frank 2016-02-01T15:24:51.000246Z

ah ok

frank 2016-02-01T15:26:19.000247Z

I guess I'll do something like ~(zipmap [:dev :whitespace :test :production] (repeat {:source-paths ["devtools"]})

2016-02-01T15:27:45.000248Z

yes, you can define it as a separate lein profile and compose lein profiles instead

2016-02-01T15:28:31.000249Z

but in this case I would just (def shared-source-paths [ā€¦]) and then use :source-paths ~(concat shared-source-paths [ā€¦])

2016-02-01T15:29:20.000250Z

more readable IMO than zipmap

frank 2016-02-01T15:39:53.000251Z

true

frank 2016-02-01T15:40:35.000252Z

I've moved the source file into a different source path but the compiler still seems to be looking for the file šŸ˜ž

frank 2016-02-01T15:40:40.000253Z

it just says it can't find it

2016-02-01T15:41:15.000254Z

lein clean? sometimes the caches are causing weird issue

2016-02-01T15:41:18.000255Z

lein clean? sometimes the caches are causing weird issues

frank 2016-02-01T15:41:27.000256Z

wait nvm

frank 2016-02-01T15:44:47.000257Z

dumb error on my part -_-

danielcompton 2016-02-01T20:12:40.000260Z

I got a bit confused by the devtools sample because it includes devtools in the main dependencies. Am I reading it wrong, or is that project going to include devtools in advanced compilation? https://github.com/binaryage/cljs-devtools-sample/blob/master/project.clj#L7

2016-02-01T23:14:16.000262Z

@danielcompton: hmm, adding something into dependencies does not mean it will be included by cljsbuild

2016-02-01T23:14:26.000263Z

for cljs compilation :source-paths of cljsbuild :build configs is the important piece, and cljs-devtools-sample didnā€™t have any :advanced build until today

2016-02-01T23:14:51.000264Z

and I added it today just to test compilation warnings under :advanced mode, not really use cljs-devtools under :advanced mode

danielcompton 2016-02-01T23:15:02.000265Z

k

danielcompton 2016-02-01T23:15:42.000266Z

What weā€™ve done is made dev-src/init.cljs, and src/init.clj. The dev-src one adds cljs-devtools, the src one doesn't

2016-02-01T23:16:07.000267Z

yes, that is what Iā€™m doing in most of my projects too

danielcompton 2016-02-01T23:16:10.000268Z

When we build for dev we add dev-src to the classpath, in prod we use the src one which is a no-op

2016-02-01T23:16:50.000269Z

classpath is not that important, important it what you put into :source-paths of cljsbuild

2016-02-01T23:17:59.000270Z

btw. alternative solution is to require devtools dynamically, by calling js/goog.require (depending on some condition)

2016-02-01T23:19:08.000271Z

weā€™ve discussed it here with frank, it is pretty flexible to use environ library and include cljs-devtools dynamically based on environmental variable

2016-02-01T23:19:23.000272Z

with lein-environ you can define that variable in project.clj

danielcompton 2016-02-01T23:26:23.000273Z

yeah sorry, classpath was the wrong term to suse

danielcompton 2016-02-01T23:27:31.000274Z

So something like (if js/goog.DEBUG (js/goog.require devtools.core))

2016-02-01T23:28:36.000275Z

yes, but you require your dev-src namespace which does its work to require devtools and calls install!

2016-02-01T23:30:05.000277Z

wait, you want to use macro to generate that js/goog.require snippet only under debug mode

2016-02-01T23:30:26.000278Z

if you generate that require under :advanced, that namespace would not be elided

2016-02-01T23:30:50.000279Z

Iā€™m not sure now js/goog.DEBUG may be special and closure compiler can elide it

2016-02-01T23:31:11.000280Z

let me find an example project with that environ variable setup

2016-02-01T23:32:18.000281Z

ah, this technique is used in cljs-devtools-sample itself: https://github.com/binaryage/cljs-devtools-sample/blob/master/src/demo/devtools_sample/boot.cljs#L31-L32

2016-02-01T23:32:34.000283Z

I require weasel dynamically here^

2016-02-01T23:35:26.000286Z

when it evals to false, I believe closure compiler elides whole code branch

2016-02-01T23:36:41.000287Z

but what frank did above, he has a macro which generates the code (js/goog.require ā€œsomethingā€) or nothing, this is the safest way I think

2016-02-01T23:37:20.000288Z

when it is not generated, there is not goog.require for something anywhere in the code, so something will be marked as a dead code and eliminated

danielcompton 2016-02-01T23:50:16.000290Z

awesome, thanks!