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.

On Wednesday, May 30, 2012 6:46:17 PM UTC-7, Stephen Cagle wrote:
>
> 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.
>
> On Wednesday, May 30, 2012 1:33:25 PM UTC-7, Evan Mezeske wrote:
>>
>> 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 .
>>
>> On Wednesday, May 30, 2012 12:15:35 PM UTC-7, Stephen Cagle wrote:
>>>
>>> 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?
>>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to