Registry / web-framework / grunt-closure-compiler

grunt-closure-compiler

JSON →
library0.0.21jsnpmunverified

A Grunt task for Google Closure Compiler, a JavaScript minifier and optimizer. The latest version is 0.0.21, but the package appears to be stale with no recent updates. It wraps the Closure Compiler JAR file, requiring manual download of the compiler. Compared to alternative Grunt plugins like grunt-contrib-uglify, this offers access to Closure Compiler's advanced optimizations. Users must handle Java dependency, set up environment variables, and manage report files. The package is limited in features and lacks modern ES module support.

npm install grunt-closure-compiler
INSTALL
IMPORT
SIG · GRUNT-CLOSURE-COMP
G
grunt-closure-compiler
web-frameworkjavascriptv0.0.21
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.

closure-compiler task
grunt.loadNpmTasks('grunt-closure-compiler');
require('grunt-closure-compiler');
This is a Grunt plugin, not a module. Use grunt.loadNpmTasks in Gruntfile
Task configuration
grunt.initConfig({ 'closure-compiler': { ... } });
grunt.initConfig({ closureCompiler: { ... } });
The task name must be 'closure-compiler' (with hyphen) in initConfig
Closure Path
closurePath: '/path/to/closure-compiler'
closurePath: '/path/to/closure-compiler/compiler.jar'
Point to the directory containing the JAR, not the JAR itself

Configures a Grunt task using grunt-closure-compiler to minify a JS file with Closure Compiler. Requires manual download of compiler.jar.

// Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ 'closure-compiler': { frontend: { closurePath: process.env.CLOSURE_PATH || '/path/to/closure-compiler', js: 'src/input.js', jsOutputFile: 'build/output.min.js', maxBuffer: 500, options: { compilation_level: 'ADVANCED_OPTIMIZATIONS' } } } }); grunt.loadNpmTasks('grunt-closure-compiler'); grunt.registerTask('default', ['closure-compiler']); };
grunt --version
Debug
Known issues
breakingRequires Java Runtime to be installed and accessible
fix
Install Java (JRE) and ensure 'java' is in PATH
affects: >=0.0.1
breakingClosure Compiler JAR must be manually downloaded; no npm dependency
fix
Download compiler.jar from https://dl.google.com/closure-compiler/compiler-latest.zip and set 'closurePath' or CLOSURE_PATH environment variable
affects: >=0.0.1
deprecatedGrunt 0.4+ compatibility issues; not updated for Grunt 1.x
fix
Use grunt-contrib-uglify or grunt-closure-compiler v0.0.21 with Grunt 0.4, or migrate to modern bundlers
affects: >=0.0.1
gotchamaxBuffer property uses kilobytes, not bytes
fix
Set maxBuffer to desired size in KB (e.g., 500 for 500KB)
affects: >=0.0.1
gotchaOutput file is overwritten without warning if it exists
fix
Ensure jsOutputFile path does not accidentally overwrite important files
affects: >=0.0.1
Errors
Common errors & fixes
maxBuffer exceeded
Closure Compiler output exceeds default buffer size (~200KB)
fix
Set 'maxBuffer' property in task config to a larger value in KB (e.g., 500)
FATAL ERROR: JAVA not found
Java Runtime is not installed or not in PATH
fix
Install Java (JRE) and ensure 'java' command is available
Error: Could not find or load main class com.google.javascript.jscomp.CommandLineRunner
closurePath is pointing to the JAR file instead of its directory, or the JAR is missing
fix
Set 'closurePath' to the directory containing compiler.jar, not the JAR itself
Upgrade
Version history
0.0.21latest on npm
Audit
Dependencies
gruntrequiredPeer dependency: this plugin requires Grunt to run
Agent activity
6 hits · last 30 days
node
6
Resources
grunt-closure-compiler — npm install grunt-closure-compiler · libregistry