{"id":20723,"library":"webpack-closure-compiler","title":"webpack-closure-compiler","description":"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.","status":"active","version":"2.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/roman01la/webpack-closure-compiler","tags":["javascript","webpack","closure","compiler","build","optimize","dead","code","plugin"],"install":[{"cmd":"npm install webpack-closure-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-closure-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-closure-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core compiler dependency; provides the actual Closure Compiler JAR or JS binaries.","package":"google-closure-compiler","optional":false}],"imports":[{"note":"This package is CommonJS-only; ESM import is not supported.","wrong":"import ClosureCompilerPlugin from 'webpack-closure-compiler';","symbol":"ClosureCompilerPlugin","correct":"const ClosureCompilerPlugin = require('webpack-closure-compiler');"},{"note":"Ensure the exported name matches exactly: ClosureCompilerPlugin.","wrong":"const { ClosureCompiler } = require('webpack-closure-compiler');","symbol":"ClosureCompilerPlugin","correct":"const { ClosureCompilerPlugin } = require('webpack-closure-compiler');"},{"note":"Must use 'new' keyword when instantiating the plugin.","wrong":"plugins: [ ClosureCompilerPlugin({...}) ]","symbol":"ClosureCompilerPlugin (Webpack 4+ syntax)","correct":"const ClosureCompilerPlugin = require('webpack-closure-compiler');\n// In webpack.config.js:\nplugins: [ new ClosureCompilerPlugin({...}) ]"}],"quickstart":{"code":"const path = require('path');\nconst ClosureCompilerPlugin = require('webpack-closure-compiler');\n\nmodule.exports = {\n  entry: path.join(__dirname, 'app.js'),\n  output: {\n    path: path.join(__dirname, 'dist'),\n    filename: 'bundle.min.js',\n  },\n  plugins: [\n    new ClosureCompilerPlugin({\n      compiler: {\n        language_in: 'ECMASCRIPT6',\n        language_out: 'ECMASCRIPT5',\n        compilation_level: 'ADVANCED',\n      },\n      concurrency: 3,\n    }),\n  ],\n};","lang":"javascript","description":"Demonstrates basic Webpack configuration using webpack-closure-compiler with ADVANCED optimizations and parallel compilation."},"warnings":[{"fix":"Run: npm i -D google-closure-compiler","message":"The plugin requires google-closure-compiler to be installed as a peer dependency, but it is not automatically installed.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use default Java mode unless you cannot install Java.","message":"JavaScript mode (jsCompiler: true) is significantly slower (2x) than the default Java-based compiler.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Do not set both concurrency and jsCompiler; choose one concurrency mode.","message":"The concurrency option is mutually exclusive with jsCompiler: true.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a newer alternative or test with Webpack 5; consider terra-untitled/webpack-closure-compiler fork.","message":"Webpack 5 compatibility is not guaranteed; this plugin was last updated before Webpack 5 release.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Use webpack's module.rules to process only certain files.","message":"The 'test' option (RegExp) to filter files is deprecated and may be removed in future versions.","severity":"deprecated","affected_versions":">=2.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install --save-dev google-closure-compiler","cause":"Missing peer dependency google-closure-compiler.","error":"Error: Cannot find module 'google-closure-compiler'"},{"fix":"Use: new ClosureCompilerPlugin({...})","cause":"Forgetting 'new' keyword when instantiating the plugin.","error":"ClosureCompilerPlugin is not a constructor"},{"fix":"Install Java SDK or add jsCompiler: true to plugin options.","cause":"Java is not installed and jsCompiler option is not set.","error":"Error: Java not found. Please install Java to use the Java-based compiler or set jsCompiler: true."},{"fix":"Ensure you pass an object with 'compiler' key: new ClosureCompilerPlugin({ compiler: {...} })","cause":"The plugin is passed something other than an object (e.g., array or null).","error":"TypeError: Cannot read property 'options' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}