npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gulp-closure-compiler

v0.4.0

Published

Gulp plugin for Google Closure Compiler

Downloads

6,052

Readme

gulp-closure-compiler

Build Status Dependency Status devDependency Status

Gulp plugin for Google Closure Compiler

Issues with the output or Java should be reported on the Closure Compiler issue tracker.

Install

npm install --save-dev gulp-closure-compiler

Example

Simple optimizations

Simple optimizations for classic minifying.

var gulp = require('gulp');
var closureCompiler = require('gulp-closure-compiler');

gulp.task('default', function() {
  return gulp.src('src/*.js')
    .pipe(closureCompiler({
      compilerPath: 'bower_components/closure-compiler/lib/vendor/compiler.jar',
      fileName: 'build.js'
    }))
    .pipe(gulp.dest('dist'));
});

Advanced optimizations

Advanced optimizations is much more aggressive. It's aimed for libraries like Closure Library.

var gulp = require('gulp');
var closureCompiler = require('gulp-closure-compiler');

gulp.task('default', function() {
  return gulp.src('src/*.js')
    .pipe(closureCompiler({
      compilerPath: 'bower_components/closure-compiler/lib/vendor/compiler.jar',
      fileName: 'build.js',
      compilerFlags: {
        closure_entry_point: 'app.main',
        compilation_level: 'ADVANCED_OPTIMIZATIONS',
        define: [
          "goog.DEBUG=false"
        ],
        externs: [
          'bower_components/este-library/externs/react.js'
        ],
        extra_annotation_name: 'jsx',
        only_closure_dependencies: true,
        // .call is super important, otherwise Closure Library will not work in strict mode.
        output_wrapper: '(function(){%output%}).call(window);',
        warning_level: 'VERBOSE'
      }
    }))
    .pipe(gulp.dest('dist'));
});

Compiling with Google Closure Library

The current version of the compiler doesn't need a deps file as it used to. Now you need to supply the directories where your dependencies are defined (via goog.provide).

var gulp = require('gulp');
var closureCompiler = require('gulp-closure-compiler');

gulp.task('default', function() {
  return gulp.src(['main.js', 'src/**/*.js', 'bower_components/closure-library/closure/goog/**/*.js'])
    .pipe(closureCompiler({
      compilerPath: 'bower_components/closure-compiler/compiler.jar',
      fileName: 'build.js',
      compilerFlags: {
        closure_entry_point: 'app.main',
        compilation_level: 'ADVANCED_OPTIMIZATIONS',
        only_closure_dependencies: true,
        warning_level: 'VERBOSE'
      }
    }))
    .pipe(gulp.dest('dist'));
});

API

closureCompiler(options)

options

fileName

Type: String
Required

Generated file name.

compilerPath

Type: String
Required

Path to compiler.jar

compilerFlags

Type: Object

Closure compiler flags.

tieredCompilation

Type: Boolean

Tiered compilation enhances the speed of compilation. It's supported everywhere since Java 1.7+, but requires the installation of a JDK.

maxBuffer

Type: Number

If the buffer returned by closure compiler is more than 1000kb, you will get an error saying "maxBuffer exceeded". To prevent this, you can set the maxBuffer to the preffered size you want (in kb).

continueWithWarnings

Type: boolean

Ignore the warnings and continue with the compiler. This adds flexiblity to some projects that can't work around certain warnings. Default value is false.

How to download Closure Compiler

Use Bower.

{
  "name": "foo",
  "version": "0.0.0",
  "dependencies": {
    "closure-compiler": "http://dl.google.com/closure-compiler/compiler-latest.zip"
  }
}

Implementation notes

  • Closure compiler supports pipes, but not correctly (issue).
  • You don't need closurebuilder.py script, compiler knows how to resolve dependencies.
  • Java 1.7+ is required.

License

MIT © Daniel Steigerwald