Search code examples
javascriptgoogle-closure-compilergoogle-closure

Can I use Google Closure only for concatenating JavaScript files?


I have a project moved into my hands recently. It uses Google Closure to compile multiple JS files into one final.js. Sometimes I need to debug final.js in the browser, but the problem is Closure always compress JavaScript code with shorten function and variable names. So I can't debug final.js properly in the browser.

My question is, is there any way to use Google Closure to just concatenate JS files without compressing?

The answer can be some CLI options or even hacking the source code.

PS. I've tried --formatting PRETTY_PRINT, but the final code still got compressed.


Solution

  • WHITESPACE_ONLY and PRETTY_PRINT get pretty close, but there isn't a "concat" only mode. The compiler does have the capability to create "output bundles" but it isn't exposed on the command-line:

    https://github.com/google/closure-compiler/blob/52ae79693589834930cbfc01fe78f4efa8f6c518/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java#L1966