Registry / devops / webpack-closure-compiler

webpack-closure-compiler

JSON →
library2.1.6jsnpmunverified

A Webpack plugin that integrates Google Closure Compiler for advanced JavaScript optimization, including dead code elimination, function inlining, and tree-shaking for AMD, CommonJS, and ES2015 modules. The current stable version is 2.1.6, with sporadic releases. It is one of the few plugins to offer Closure Compiler's ADVANCED mode optimizations directly in Webpack, producing smaller bundles than UglifyJS. It supports both Java-based and pure JavaScript (jsCompiler) modes, with concurrency options for parallel compilation. Maintained as open-source, but note limited activity and no recent major updates.

npm install webpack-closure-compiler
INSTALL
IMPORT
SIG · WEBPACK-CLOSURE-CO
W
webpack-closure-compiler
devopsjavascriptv2.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

ClosureCompilerPlugin
const ClosureCompilerPlugin = require('webpack-closure-compiler');
import ClosureCompilerPlugin from 'webpack-closure-compiler';
This package is CommonJS-only; ESM import is not supported.
ClosureCompilerPlugin
const { ClosureCompilerPlugin } = require('webpack-closure-compiler');
const { ClosureCompiler } = require('webpack-closure-compiler');
Ensure the exported name matches exactly: ClosureCompilerPlugin.
ClosureCompilerPlugin (Webpack 4+ syntax)
const ClosureCompilerPlugin = require('webpack-closure-compiler'); // In webpack.config.js: plugins: [ new ClosureCompilerPlugin({...}) ]
plugins: [ ClosureCompilerPlugin({...}) ]
Must use 'new' keyword when instantiating the plugin.

Demonstrates basic Webpack configuration using webpack-closure-compiler with ADVANCED optimizations and parallel compilation.

const path = require('path'); const ClosureCompilerPlugin = require('webpack-closure-compiler'); module.exports = { entry: path.join(__dirname, 'app.js'), output: { path: path.join(__dirname, 'dist'), filename: 'bundle.min.js', }, plugins: [ new ClosureCompilerPlugin({ compiler: { language_in: 'ECMASCRIPT6', language_out: 'ECMASCRIPT5', compilation_level: 'ADVANCED', }, concurrency: 3, }), ], };
Debug
Known issues
gotchaThe plugin requires google-closure-compiler to be installed as a peer dependency, but it is not automatically installed.
fix
Run: npm i -D google-closure-compiler
affects: >=2.0.0
gotchaJavaScript mode (jsCompiler: true) is significantly slower (2x) than the default Java-based compiler.
fix
Use default Java mode unless you cannot install Java.
affects: >=1.0.0
gotchaThe concurrency option is mutually exclusive with jsCompiler: true.
fix
Do not set both concurrency and jsCompiler; choose one concurrency mode.
affects: >=1.0.0
breakingWebpack 5 compatibility is not guaranteed; this plugin was last updated before Webpack 5 release.
fix
Use a newer alternative or test with Webpack 5; consider terra-untitled/webpack-closure-compiler fork.
affects: >=2.0.0 <3.0.0
deprecatedThe 'test' option (RegExp) to filter files is deprecated and may be removed in future versions.
fix
Use webpack's module.rules to process only certain files.
affects: >=2.1.0
Errors
Common errors & fixes
Error: Cannot find module 'google-closure-compiler'
Missing peer dependency google-closure-compiler.
fix
Run: npm install --save-dev google-closure-compiler
ClosureCompilerPlugin is not a constructor
Forgetting 'new' keyword when instantiating the plugin.
fix
Use: new ClosureCompilerPlugin({...})
Error: Java not found. Please install Java to use the Java-based compiler or set jsCompiler: true.
Java is not installed and jsCompiler option is not set.
fix
Install Java SDK or add jsCompiler: true to plugin options.
TypeError: Cannot read property 'options' of undefined
The plugin is passed something other than an object (e.g., array or null).
fix
Ensure you pass an object with 'compiler' key: new ClosureCompilerPlugin({ compiler: {...} })
Upgrade
Version history
2.1.6latest on npm
Audit
Dependencies
google-closure-compilerrequiredCore compiler dependency; provides the actual Closure Compiler JAR or JS binaries.
Agent activity
13 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
webpack-closure-compiler — npm install webpack-closure-compiler · libregistry