Although the Closure Compiler can be used with various JavaScript libraries, the greatest advantage is achieved when used with the Closure Library , which has its own module and dependency system. Web applications that use the Closure library are usually compiled into a single JavaScript file, which does not require loading an asynchronous module. However, Closure provides support for modules that can be loaded asynchronously. Chad Killingsworth served as a good example of how to configure modules here . In addition, the plovr tool provides add -on module support to simplify their use.
If you decide to use the Closure compiler (and you are not tied to a large AMD codebase), you are likely to maximize performance by adopting the Closure library and its module / dependency system in your new code. If you plan to use the AMD codebase, then as you mentioned, the new Compiler experimental flags --transform_amd_modules and --process_common_js_modules can help, but if you use human libraries, you will miss most of the compiler features.
Looking to the future, if ECMAScript Harmony Modules become an official standard, then it is likely that libraries such as Closure, Dojo, and YUI will eventually conform to this standard. Ultimately, this will make it easy to integrate JavaScript code from disparate libraries. At the same time, if you want to write JavaScript applications and use type checking, eliminating dead codes, minimizing, advanced memory management, browser agnosticism and a phenomenal standard library, I highly recommend using the Closure compiler in combination with the Closure Library.
Christopher peisert
source share