开发者

help with google closure compiler basics

I'm having trouble understanding the basic flow of using the google closure compiler API service. I'll just fire away with some questions:

  1. Am I supposed to include closure's base.js in the list of files I send to be compiled?
  2. deps.js is too large to send. Am I supposed to include it myself, or will the compiler service use its own copy?
  3. It was my understanding that one of the features of the compiler is that it parses the "require" statements, and includes the necessary code in the output. For example, if I go to the online UI tool they provide and type the following into the input box:

    goog.require("goog.dom");
    goog.dom.getElement("test");
    

and press "compile", I would expect to get back just enough of the google closure code to execute this snippet. Instead, I just get the same thing back (minus whitespace). What am I not understanding?

And finally, google's compiler service has a 200k size restriction on the files you send in. I'm using a PHP package called Minify, that lets you send a list of files, which are sent through the service one at a time, and presumably this is how google expects you to deal with the 200k limit. The compiler is supposed to be checking, say, that none of your private variables are being accessed as public anywhere, which seems to imply that it would have to have knowledge of all the files in the list to make sure that a class defined in file A is not being violated in file B. Is this the case? Does the service somehow remember each file as its par开发者_StackOverflow社区sed, keep it in memory, and cross-check everything? Or is my understanding yet flawed?

Thanks, guys!


If you select the "Closure Library" from the drop down for "add a url", to the configurations it will add:

// @ use_closure_library=true

This will cause the webservice to include the source for "goog.require" that can be satisfied by closure-library itself. If any of your goog.requires must be satisfied by your own code, you must include the URL manually.

At some point you likely want to run your own compilation service for which you might find Michael Bolin's Plovr project useful:

http://code.google.com/p/plovr/


I've created a Google Closure project template called Shoreline. It contains everything needed to create, test, and compile a Closure project locally. No code size restrictions and no uptime concerns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜