This isn't a rewrite of Closure in JavaScript. Instead, we compile the Java
source to JS to run under Node, or even inside a plain old browser. Every post
or resource you see about Closure Compiler will also apply to this version.
Note that the JS version is experimental. It may not perform in the same way as
the native Java version, but we believe it's an interesting new addition to the
compiler landscape, and the Closure team will be working to improve and support
it over time.
How can I use it?
To include the JS version of Closure Compiler in your project, you should add it
as a dependency of your project via NPM-
npm install --save-dev google-closure-compiler-js
To then use the compiler with Gulp,
you can add a task like this-
If you'd like to migrate from google-closure-compiler (which requires Java),
you'll have to use gulp.src() or equivalents to load your JavaScript before it
can be compiled. As this compiler runs in pure JavaScript, the compiler cannot
load or save files from your filesystem directly.
For more information, check out Usage,supported
Flags, or a demo
project. Not all flags supported in the Java release are currently available
in this experimental version. However, the compiler will let you know via
exception if you've hit any missing ones.