Registry / devops / closure-webpack-plugin

closure-webpack-plugin

JSON →
library2.6.1jsnpmunverified

A webpack plugin integrating Google Closure Compiler and Closure Library for JavaScript optimization and transpilation. Version 2.6.1 (webpack 4 branch) requires google-closure-compiler >=20200830.0.0 and webpack 4.x. Offers three platforms (native, Java, JavaScript) and two modes (STANDARD for minification/transpilation, AGGRESSIVE_BUNDLE for advanced module hoisting and optimization). Unlike TerserPlugin or Babel, it provides full Closure Compiler optimizations including dead code elimination, type checking, and cross-module analysis. Not compatible with webpack 5.

npm install closure-webpack-plugin
INSTALL
IMPORT
SIG · CLOSURE-WEBPACK-PL
C
closure-webpack-plugin
devopsjavascriptv2.6.1
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.

ClosurePlugin
const ClosurePlugin = require('closure-webpack-plugin');
import ClosurePlugin from 'closure-webpack-plugin';
Package does not provide a default ESM export; require() is required.
ClosurePlugin
import ClosurePlugin = require('closure-webpack-plugin');
import * as ClosurePlugin from 'closure-webpack-plugin';
In TypeScript, use `import = require()` for proper CommonJS interop; namespace import may fail.
ClosurePlugin as ClosurePlugin
const { ClosurePlugin } = require('closure-webpack-plugin');
const { default: ClosurePlugin } = require('closure-webpack-plugin');
No default export; use named export if the package's TypeScript typings allow it (but check actual typings).

Basic webpack config using closure-webpack-plugin as the minifier with JavaScript platform, STANDARD mode, and debug flags.

const ClosurePlugin = require('closure-webpack-plugin'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: __dirname + '/dist' }, optimization: { minimizer: [ new ClosurePlugin({ mode: 'STANDARD', platform: 'javascript' }, { // compiler flags formatting: 'PRETTY_PRINT', debug: true, renaming: false }) ] } };
Debug
Known issues
breakingPlugin only works with webpack 4.x; not compatible with webpack 5.
fix
Use webpack 4 or switch to an alternative plugin for webpack 5.
affects: >=2.0.0
gotchaDo not set compiler flags module_resolution, output_wrapper, dependency_mode, create_source_map, module, or entry_point—they are controlled by the plugin and will conflict.
fix
Remove these flags from the compiler options object. They are overridden internally.
affects: >=1.0.0
deprecatedThe 'platform' option accepts strings 'native', 'java', 'javascript', but old documentation used case-insensitive values.
fix
Use lowercase strings as above. The plugin may also accept uppercase but it's not guaranteed.
affects: >=2.0.0
gotchaAGGRESSIVE_BUNDLE mode hoists require() calls, which can cause out-of-order execution if polyfills or side-effects are interleaved.
fix
Ensure modules with side-effects are separated into different chunks or mark them with sideEffects: false in package.json.
affects: >=1.0.0
gotchachildCompilations defaults to false—plugins like html-webpack-plugin may not get optimized output.
fix
Set childCompilations: true or a custom function if child compilations need closure optimization.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ClosurePlugin is not a constructor
Importing the plugin incorrectly (using default import instead of require).
fix
Use `const ClosurePlugin = require('closure-webpack-plugin');`
Error: Cannot find module 'google-closure-compiler'
Required peer dependency not installed.
fix
Run `npm install --save-dev google-closure-compiler`
Error: webpack version 5.x is not supported
Using the plugin with webpack 5.
fix
Downgrade to webpack 4.x, or use an alternative plugin (e.g., terser-webpack-plugin) for webpack 5.
Upgrade
Version history
2.6.1latest on npm
Audit
Dependencies
google-closure-compilerrequiredPeer dependency providing the Closure Compiler binary; must be installed separately.
webpackrequiredPeer dependency; only compatible with webpack 4.x.
Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
1
Resources
closure-webpack-plugin — npm install closure-webpack-plugin · libregistry