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
our CI tests grep for warnings in the cljsbuild log so I can't get my build to pass š
patch welcome, or disable sanity-hints feature in cljs-devtools
oh, wait maybe disabling it wonāt help, this is compile-time warning I guess
not sure if this can be rewritten somehow: https://github.com/binaryage/cljs-devtools/blob/master/src/devtools/sanity_hints.cljs#L94
I wonder what the compiler's issue is with that
does it have warnings whenever you use the this-as
macro?
I think that warning is a relatively recent thing in google closure compiler, this-as could have been written/designed before
https://developers.google.com/closure/compiler/docs/limitations?hl=en
now I understand the issue
actually my code in cljs-devtools is using this-as in prototype method, but it is not obvious to closure compiler
ah I see
it thinks it's a static method
so this warning shows up only when compiling under :advanced mode?
Iām not seeing it normally
maybe if type-error-to-string
was an anonymous function, it could get the compiler to successfully detect it as a prototype method?
ok, Iām going to try it
yes, this is with :advanced
optimizations
i think you could just remove cljs-devtools from advanced build
it doesnāt work under advanced anyways
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
I'm requiring it with a macro as you suggested a few days earlier
(defmacro require-devtools! []
(when (:devtools env)
'(js/goog.require "frontend.devtools")))
I think because this source file is still in my source path
I may need to move it out
good, and also remove frontend/devtools folder from cljs-buildās source-paths
@frank: the fix worked: https://github.com/binaryage/cljs-devtools/commit/e5fad13e4565ddeac59ed06cfe551455b47303f2
nice!
thanks for helping me sort out my lein dependencies too :simple_smile:
source paths and whatnot
youāre welcome :simple_smile:
is there a way to set a common source path for all lein cljsbuild
profiles?
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"]]}}
as you can see i'm specifying :source-paths
several times š
you can use ~(<code>) to eval arbitrary <code> within leiningen project.clj
but that might be tricky, if some other tool reads project.clj directly
e.g. Cursive or maybe your own tasks
that being said, Iām not aware of any lein-cljsbuild feature which would allow you to compose builds somehow
ah ok
I guess I'll do something like ~(zipmap [:dev :whitespace :test :production] (repeat {:source-paths ["devtools"]})
yes, you can define it as a separate lein profile and compose lein profiles instead
but in this case I would just (def shared-source-paths [ā¦]) and then use :source-paths ~(concat shared-source-paths [ā¦])
more readable IMO than zipmap
true
I've moved the source file into a different source path but the compiler still seems to be looking for the file š
it just says it can't find it
lein clean? sometimes the caches are causing weird issue
lein clean? sometimes the caches are causing weird issues
wait nvm
dumb error on my part -_-
@darwin: thanks for your comment on http://dev.clojure.org/jira/browse/CLJS-1545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42130#comment-42130
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
@danielcompton: hmm, adding something into dependencies does not mean it will be included by cljsbuild
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
and I added it today just to test compilation warnings under :advanced mode, not really use cljs-devtools under :advanced mode
k
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
yes, that is what Iām doing in most of my projects too
When we build for dev we add dev-src
to the classpath, in prod we use the src one which is a no-op
classpath is not that important, important it what you put into :source-paths of cljsbuild
btw. alternative solution is to require devtools dynamically, by calling js/goog.require (depending on some condition)
weāve discussed it here with frank, it is pretty flexible to use environ library and include cljs-devtools dynamically based on environmental variable
with lein-environ you can define that variable in project.clj
yeah sorry, classpath was the wrong term to suse
So something like (if js/goog.DEBUG (js/goog.require devtools.core))
yes, but you require your dev-src namespace which does its work to require devtools and calls install!
wait, you want to use macro to generate that js/goog.require snippet only under debug mode
if you generate that require under :advanced, that namespace would not be elided
Iām not sure now js/goog.DEBUG may be special and closure compiler can elide it
let me find an example project with that environ variable setup
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
I require weasel dynamically here^
weasel is just a simple macro: https://github.com/binaryage/cljs-devtools-sample/blob/master/src/demo/devtools_sample/config.clj#L7-L8
when it evals to false
, I believe closure compiler elides whole code branch
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
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
awesome, thanks!