Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Closure Error with externs

I'm getting errors with Warnings like this. when I use a command line for Google Closure app. Does anyone know how to stop this. I had all Jquery code including jquery plugins set in my --externs like below.

java -jar compiler-latest/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js deploy/js/mainMenu.js --js deploy/js/Home.js --js_output_file deploy/js/Home-min.js --externs deploy/js/jquery-1.6.1.js --externs deploy/js/jquery.backgroundPosition.js --externs deploy/js/jquery.color.js --externs deploy/js/jquery.easing.1.3.js

WARNING -

deploy/js/jquery.backgroundPosition.js:11: WARNING - accessing name name in externs has no effect
            if(name === 'background-position'){
               ^
like image 755
Chapsterj Avatar asked Jul 07 '11 14:07

Chapsterj


People also ask

Does the Closure Compiler service support externs?

Both the Closure Compiler application and the Closure Compiler service API allow extern declarations. However, the Closure Compiler service UI does not provide an interface element for specifying externs files. There are three ways to send an extern declaration to the Closure Compiler service:

What is an externs file?

Externs are files that look very much like normal JavaScript annotated for Closure Compiler. The main difference is that their contents are never printed as part of the compiled output, so none of the values are meaningful, only the names and types. Below is an example of an externs file for a simple library.

How do I include an external library in Closure Compiler?

To do this, include a file containing the externs for the external library into your compilation. That will tell Closure Compiler which names you do not control and therefore cannot be changed. Your code must use the same names that the external file uses. Common examples of this are APIs like the OpenSocial API and the Google Maps API.

What are externs in C++?

Externs are declarations that tell Closure Compiler the names of symbols that should not be renamed during advanced compilation. They are called externs because these symbols are most often defined by code outside the compilation, such a native code, or third-party libraries.


1 Answers

You should generally use extern files that are written for that purpose. Such as:

http://code.google.com/p/closure-compiler/source/browse/trunk/contrib/externs/jquery-1.6.js

For definitions that is not overly dynamic (jQuery core does not fall into this category), you can use the source like you are trying to do and in that case you can silence the warnings with:

--jscomp_off=externsValidation

like image 189
John Avatar answered Oct 17 '22 06:10

John