Registry / devops / gulp-closure-compiler

gulp-closure-compiler

JSON →
library0.4.0jsnpmunverified

Gulp plugin for Google Closure Compiler that integrates the Closure Compiler Java-based minification and optimization into Gulp build pipelines. Version 0.4.0 (latest) is a stable release with no active development since 2016. It provides SIMPLE and ADVANCED optimization modes, supports custom compiler flags, tiered compilation, and maxBuffer configuration. Unlike alternatives like gulp-google-closure-compiler, this plugin requires a local compiler.jar and does not use the npm-based compiler distribution.

npm install gulp-closure-compiler
INSTALL
IMPORT
SIG · GULP-CLOSURE-COMPI
G
gulp-closure-compiler
devopsjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

closureCompiler
import closureCompiler from 'gulp-closure-compiler'
const { closureCompiler } = require('gulp-closure-compiler')
Default export: use default import or require(). No named export.
default (function)
const closureCompiler = require('gulp-closure-compiler')
import { closureCompiler } from 'gulp-closure-compiler'
CommonJS: require returns the function directly. No named import.
Type (none)
// No types provided; use @types/gulp-closure-compiler if needed
import * as closureCompiler from 'gulp-closure-compiler'
No TypeScript types included. Use any or install @types/gulp-closure-compiler from DefinitelyTyped (may be outdated).

Basic Gulp task using SIMPLE optimization with a local closure-compiler.jar.

var gulp = require('gulp'); var closureCompiler = require('gulp-closure-compiler'); gulp.task('default', function() { return gulp.src('src/*.js') .pipe(closureCompiler({ compilerPath: 'path/to/compiler.jar', fileName: 'build.js' })) .pipe(gulp.dest('dist')); });
Debug
Known issues
gotchacompilerPath must point to a local compiler.jar file. The package does not download or bundle the compiler.
fix
Download compiler.jar from https://dl.google.com/closure-compiler/compiler-latest.zip and set compilerPath.
affects: >=0.0.0
gotchaADVANCED_OPTIMIZATIONS requires proper externs and closure_entry_point, otherwise code may be incorrectly removed.
fix
Provide externs for external APIs and set closure_entry_point as the main entry.
affects: >=0.0.0
deprecatedThe package is no longer maintained. Consider using gulp-google-closure-compiler or closure-compiler-npm directly.
fix
Migrate to gulp-google-closure-compiler or use the official npm closure-compiler package.
affects: >=0.4.0
gotchamaxBuffer default is 1000kb (in code). If output exceeds this, you get 'maxBuffer exceeded' error.
fix
Set maxBuffer option to a higher value in kilobytes.
affects: >=0.3.0
gotchaTiered compilation requires JDK 1.7+ and may cause issues on some systems.
fix
Ensure JDK is installed and set tieredCompilation: true only if needed.
affects: >=0.3.0
Errors
Common errors & fixes
Error: spawn java ENOENT
Java is not installed or not in PATH.
fix
Install Java JRE/JDK and ensure 'java' command is available.
maxBuffer exceeded
Closure Compiler output exceeds default buffer size (1000kb).
fix
Pass maxBuffer option: maxBuffer: 2000 for 2MB.
Cannot find module 'gulp'
gulp is not installed as a peer dependency.
fix
Run 'npm install gulp --save-dev'.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
gulprequiredpeer dependency for Gulp plugin
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-closure-compiler — npm install gulp-closure-compiler · libregistry