How do I suppress warnings in a Clojurescript compilation?

750 views
Skip to first unread message

Stephen Cagle

unread,
May 30, 2012, 3:15:35 PM5/30/12
to clo...@googlegroups.com
When I compile in advanced mode, I get thousands of warnings of the nature

May 30, 2012 11:22:23 AM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/stephen/work/rpc/jquery-1.7.2.min.js:2: WARNING - accessing name a in externs has no effect
function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close();d=cl.createElement(a),cl.body.a... (It goes on for around a hundred something lines)

Where 'a' can be any variable. This results in wall clock compilation time of 63 minutes, but user compilation time of 4 minutes (if I remember correctly). My java processor usage is hovering at just a few percentage points.

I assume this means that it is spending all its time printing out these warning messages to me. Is there way in my project file to tell Clojurescript to not print the warnings?

David Nolen

unread,
May 30, 2012, 3:18:48 PM5/30/12
to clo...@googlegroups.com
Need more information. How are you compiling? Which version of CLJS? etc.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Evan Mezeske

unread,
May 30, 2012, 4:33:25 PM5/30/12
to clo...@googlegroups.com
It sounds to me like you're using a plain JavaScriupt file as an externs definition.  If that's the case, one way to get rid of the warnings is to clean up the externs file so that it only contains the function/variable names that are meant to be publicly used.  As an example, here's the externs file for jquery: https://github.com/ibdknox/jayq/blob/master/resources/externs/jquery.js .

Stephen Cagle

unread,
May 30, 2012, 9:46:17 PM5/30/12
to clo...@googlegroups.com
David,

I am depending on lein-cljsbuild "0.1.10"

I am compiling by typing > lein cljsbuild once

This is the content of my project.clj's cljsbuild section:

:cljsbuild {:crossovers [rpc.tree]
               :builds [{:source-path "src/rpc/client"
                          :compiler {:output-to "resources/public/main.js"
                                      :optimizations :advanced
                                      :externs ["jquery-1.7.2.min.js"]
                                      :pretty-print true}}]}

Evan,
Yes, I imagine that would fix it, as jayqe is the dependency I am using that seems to cause these issues. I know nothing about it, but is it unreasonable to expect the closure compiler to just "figure it out" for itself? Will modifying the jquery code manually generate substantially different code than letting closure figure out which jquery resources I am actually using? I am curious.

Evan Mezeske

unread,
May 30, 2012, 11:43:58 PM5/30/12
to clo...@googlegroups.com
Unfortunately, I have not been able to find even a decent resource on the general topic of creating extern definition files.  So, please take this with a grain of salt, and let's hope someone more knowledgeable can come along and clear things up.

My belief is that using an unmodified JS file as an externs file will most likely result in an overeager list of unmanglable names being used  when minifying your compiled JS.  There's plenty of names mentioned in the jQuery sources that are not meant to be called publicly, and I expect that the closure compiler doesn't know that.

Another problem arises due the extremely dynamic nature of JS -- it's not possible statically to tell what fields an object might have, since they can be added dynamically, etc.  It would be trivial to write a contrived example where the compiler couldn't know not to mangle a particular name.

Aaaanyway, the best solution for your specific case is to just change your :externs to ["externs/jquery.js"].  The jayq JAR contains this resource, and it has already been hand-built to be used as an externs file.

Evan Mezeske

unread,
May 30, 2012, 11:51:23 PM5/30/12
to clo...@googlegroups.com
I also meant to mention that there are a ton of knobs on the closure compiler that are not exposed by the ClojureScript compiler.  This is something I'd like to improve (or see improved) at some point, but it's a tricky problem, due to the vast number of options [1].  I expect the only way to really expose them all would be to add a hook where user code could set the options object before compiling.

It does look like there is an option that *might* disable the warnings you're seeing: DiagnosticGroups.EXTERNS_VALIDATION [2].  I haven't tested this, so I'm not sure if it would quiet down the "X has no effect" messages or not.  At any rate, there's no easy way to tweak this setting with ClojureScript.
Reply all
Reply to author
Forward
0 new messages