Wednesday, August 31, 2016 | 7:26 PM

Labels: gulp, java, javascript, webpack

Cross-posted from the Google Developers Blog



The Closure Compiler was originally released, in Java, back in 2009 . Today, we're announcing the very same Closure Compiler is now available in pure JavaScript , for use without Java. It's designed to run under NodeJS with support for some popular build tools.



If you've not heard of the Closure Compiler, it's a JavaScript optimizer, transpiler and typechecker, which compiles your code into a high-performance, minified version. Nearly every web frontend at Google uses it to serve the smallest, fastest code possible.



It supports new features in ES2015, such as let, const, arrow functions, and provides polyfills for ES2015 methods not supported everywhere. To help you write better, maintainable and scalable code, the compiler also checks syntax, correct use of types, and provides warnings for many JavaScript gotchas. To find out more about the compiler itself, including tutorials, head to Google Developers .









How does this work?





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.



To find out more about Closure Compiler's internals, be sure to check out this post by Dimitris (who works on the Closure team at Google), other posts on the Closure Tools blog, or read an exploratory post about Closure and how it can help your project in 2016.



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-



