please help with externs

83 views
Skip to first unread message

CODEY

unread,
May 21, 2013, 6:18:25 PM5/21/13
to closure-comp...@googlegroups.com
I am using jstree, and i have some code that does this: 

.bind("select_node.jstree", function (e, data) {
   var theobj = data.rslt.obj.data("theobj");
  // .... 
});

closure compiler is renaming the data.rslt.obj.data and so it is not working .. but how to write this in an externs file?


CODEY

unread,
May 21, 2013, 6:53:21 PM5/21/13
to closure-comp...@googlegroups.com
I do not understand, if I include jstree as an external file, then why does it still compile it incorrectly?

Why do i have to search the internet for an extern file, or learn how to make it myself? ... it seems to me closure compiler is supposed to read the extern js files and appropriately compile ... is it just not very good, or am i doing something wrong ... ?  every time i use a new library the compiler part breaks .. this is very frustrating ... anyone have luck with those expensive obfuscators? .. i could care less about minifying, i only want obfuscation

Johannes Nel

unread,
May 21, 2013, 8:39:38 PM5/21/13
to closure-comp...@googlegroups.com
what does your extern file look like?

maybe just use obj['key'] notation?


--
 
---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
j:pn
\\no comment

CODEY

unread,
May 21, 2013, 8:52:00 PM5/21/13
to closure-comp...@googlegroups.com
My extern file ... you dont really want to know .. i have about 10 of them .. i compile with externs like all the jquery libraries i use, then i have html5 externs because for some reason google does not realize people use html5, ... then i have jquery ui externs i found from some other people ... one by one each of these helped remove issues ... but now i have only the problem with jsTree ... i did try what you said actually, the string notation .. 

actually i think you are right, this mght be working now something else is not .. it is extremely hard to get closure compiler to work after changing code ... 

i will post more specific information once i try a couple more times
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Johannes Nel

unread,
May 21, 2013, 9:34:18 PM5/21/13
to closure-comp...@googlegroups.com
I think you are being overly negative, the closure compiler is extremely solid, In all the time (almost 2 years) I have worked with the library and compiler I have only found one serious bug (in the library). 
If you are struggling with compiled code, enable source maps, what is your approach, what are you compiling with?  


To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ed Pataky

unread,
May 22, 2013, 1:33:42 AM5/22/13
to closure-comp...@googlegroups.com
you may be right but if i provide the jsTree file as an extern, why should it not understand javascript and just work properly?
You received this message because you are subscribed to a topic in the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-compiler-discuss/R870qeYWG04/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to closure-compiler-d...@googlegroups.com.

Ed Pataky

unread,
May 22, 2013, 3:20:03 AM5/22/13
to closure-comp...@googlegroups.com
you may be right but if i provide the jsTree file as an extern, why should it not understand javascript and just work properly?

On Tuesday, May 21, 2013, Johannes Nel wrote:
You received this message because you are subscribed to a topic in the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-compiler-discuss/R870qeYWG04/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to closure-compiler-d...@googlegroups.com.

Alan Leung

unread,
Jun 3, 2013, 4:16:36 PM6/3/13
to closure-comp...@googlegroups.com
Just my $.2.

1) The 'minification' and 'obfuscation' that Closure Compiler doing in advance mode is a undecidable problem (http://en.wikipedia.org/wiki/Undecidable_problem). Extern files is a way to hint the compiler what you are doing so we can solve it. It is very easy to construct proof you cannot write a compiler that automatically do this type of work. Setting put extern files require some effort but it is not difficult. The contributors as well as some users on this list are very helpful if you need any assistant.

2) Another thing I would like to point out is that the 'obfuscation' is only a sideeffect of the 'minification' that Closure Compiler perform on the code. I wouldn't claim that Closure Compiler is a 'obfuscating compiler'. 



Erik Neumann

unread,
Jun 3, 2013, 7:12:11 PM6/3/13
to closure-comp...@googlegroups.com
Are you aware of the file at
closure-compile/externs/html5.js
?

On Tue, May 21, 2013 at 5:52 PM, CODEY <ed.p...@gmail.com> wrote:
then i have html5 externs because for some reason google does not realize people use html5,

Here is just a small bit of it's contents:
/**
 * @constructor
 * @extends {HTMLElement}
 */
function HTMLCanvasElement() {}

/** @type {number} */
HTMLCanvasElement.prototype.width;

/** @type {number} */
HTMLCanvasElement.prototype.height;

/**
 * @param {string=} opt_type
 * @return {string}
 * @throws {Error}
 * @nosideeffects
 */
HTMLCanvasElement.prototype.toDataURL = function(opt_type) {};

/**
 * @param {string} contextId
 * @param {Object=} opt_args
 * @return {Object}
 */
HTMLCanvasElement.prototype.getContext = function(contextId, opt_args) {};

/**
 * @constructor
 */
function CanvasRenderingContext2D() {}

/** @type {HTMLCanvasElement} */
CanvasRenderingContext2D.prototype.canvas;

/**
 * @return {undefined}
 */
CanvasRenderingContext2D.prototype.save = function() {};

/**
 * @return {undefined}
 */
CanvasRenderingContext2D.prototype.restore = function() {};

/**
 * @param {number} x
 * @param {number} y
 * @return {undefined}
 */
CanvasRenderingContext2D.prototype.scale = function(x, y) {};

Ed Pataky

unread,
Jun 3, 2013, 8:22:38 PM6/3/13
to closure-comp...@googlegroups.com
I think at the time i started using CC it did not exist, but can you give the full link of these files?  

I will definitely take a look .. 

i did find a solution for jstree, the jquery ui externs file plus this stuff below, not sure where i got it


/**
* @param {*=} arg1
* @return {*}
*/
jQuery.jstree;

/**
* @param {*=} arg1
* @param {*=} arg2
* @param {*=} arg3
* @param {*=} arg4
* @return {*}
*/
jQuery.prototype.jstree = function (arg1, arg2, arg3, arg4) { };

/**
* @param {*=} arg1
* @return {jQuery}
*/
jQuery.prototype.datepicker = function (arg1) { };

/**
* @param {*=} arg1
* @return {jQuery}
*/
jQuery.jstree._reference = function (arg1) { };

jQuery.jstree._reference.prototype.close_all = function () { };
jQuery.jstree._reference.prototype.refresh = function () { };
/**
* @param {*=} arg1
*/
jQuery.jstree._reference.prototype.toggle_node = function (arg1) { };





--
 
---
You received this message because you are subscribed to a topic in the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-compiler-discuss/R870qeYWG04/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to closure-compiler-d...@googlegroups.com.

Erik Neumann

unread,
Jun 3, 2013, 8:59:11 PM6/3/13
to closure-comp...@googlegroups.com
One place to look for externs like html5.js is here:

Are you using Closure Compiler Application or Service or something else?

I think I got all those externs because I checked out the entire source code for the compiler and built it myself -- it was extremely easy to do.  Here are some notes I wrote about the process:

Command to checkout the code:
    svn checkout http://closure-compiler.googlecode.com/svn/trunk/ closure-compiler

From Michael Bolin book on Closure Compiler:
  It is also fairly easy to build the Compiler from source. Download the code using
  Subversion by following the Closure Library example, but use
  http://closure-compiler.googlecode.com/svn/trunk/ as the URL of the repository to
  check out and closure-compiler as the destination. The Compiler can then be built
  using ApacheAnt:
    cd ~/closure/closure-compiler/
    ant jar
  The result will be in ~/closure/closure-compiler/build/compiler.jar.

To see compiler options:
  java -jar closure-compiler/build/compiler.jar --help

There has been talk of moving to use git instead of subversion, I'm not sure where that stands for the compiler.

Regards,
ErikN

Ed Pataky

unread,
Jun 4, 2013, 10:01:33 PM6/4/13
to closure-comp...@googlegroups.com
I am using the jar file


Erik Neumann

unread,
Jun 5, 2013, 1:46:05 AM6/5/13
to closure-comp...@googlegroups.com
Hi Ed,
I'm using closureBuilder (which I recommend you try) so I can't exactly address how it works when using the jar file by itself.  I would imagine you could use the --externs compiler flag to tell it where a whole directory of externs files are?

I think they don't package the externs with the compiler when you get the jar file.  Try downloading that whole externs directory and get the compiler to find it.  

Try to write a super-simple program that mis-uses a type that you care about from an externs.  If the compiler complains that you aren't using the type correctly then you know it is finding the externs.

Regards,
--ErikN


--
 
---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.

Ed Pataky

unread,
Jun 5, 2013, 1:50:21 AM6/5/13
to closure-comp...@googlegroups.com
ok i am not sure what the builder is, but if it is a server based service i could not use it, since i am concerned about sending raw source out on the internet .. if it is something i can download i will try it .. i will check it out .. about the externs . i am sure it is including them because as i said it took a long time adding many many externs to get it to work with all the jquery libraries i use ... i will check it out

ed

Erik Neumann

unread,
Jun 5, 2013, 12:10:40 PM6/5/13
to closure-comp...@googlegroups.com
ClosureBuilder is a stand-alone python script.

Note that the Google docs are remiss in mentioning that goog/deps.js needs to be included in the compilation.  See issue 565

Regards,
--ErikN

Ed Pataky

unread,
Jun 5, 2013, 3:57:28 PM6/5/13
to closure-comp...@googlegroups.com
interesting, i have been using my own custom python script .. i will definitely check it out
Reply all
Reply to author
Forward
0 new messages