{"id":19407,"library":"closure-webpack-plugin","title":"closure-webpack-plugin","description":"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.","status":"active","version":"2.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/webpack-contrib/closure-webpack-plugin","tags":["javascript"],"install":[{"cmd":"npm install closure-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add closure-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add closure-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency providing the Closure Compiler binary; must be installed separately.","package":"google-closure-compiler","optional":false},{"reason":"Peer dependency; only compatible with webpack 4.x.","package":"webpack","optional":false}],"imports":[{"note":"Package does not provide a default ESM export; require() is required.","wrong":"import ClosurePlugin from 'closure-webpack-plugin';","symbol":"ClosurePlugin","correct":"const ClosurePlugin = require('closure-webpack-plugin');"},{"note":"In TypeScript, use `import = require()` for proper CommonJS interop; namespace import may fail.","wrong":"import * as ClosurePlugin from 'closure-webpack-plugin';","symbol":"ClosurePlugin","correct":"import ClosurePlugin = require('closure-webpack-plugin');"},{"note":"No default export; use named export if the package's TypeScript typings allow it (but check actual typings).","wrong":"const { default: ClosurePlugin } = require('closure-webpack-plugin');","symbol":"ClosurePlugin as ClosurePlugin","correct":"const { ClosurePlugin } = require('closure-webpack-plugin');"}],"quickstart":{"code":"const ClosurePlugin = require('closure-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    filename: 'bundle.js',\n    path: __dirname + '/dist'\n  },\n  optimization: {\n    minimizer: [\n      new ClosurePlugin({\n        mode: 'STANDARD',\n        platform: 'javascript'\n      }, {\n        // compiler flags\n        formatting: 'PRETTY_PRINT',\n        debug: true,\n        renaming: false\n      })\n    ]\n  }\n};","lang":"javascript","description":"Basic webpack config using closure-webpack-plugin as the minifier with JavaScript platform, STANDARD mode, and debug flags."},"warnings":[{"fix":"Use webpack 4 or switch to an alternative plugin for webpack 5.","message":"Plugin only works with webpack 4.x; not compatible with webpack 5.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Remove these flags from the compiler options object. They are overridden internally.","message":"Do 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use lowercase strings as above. The plugin may also accept uppercase but it's not guaranteed.","message":"The 'platform' option accepts strings 'native', 'java', 'javascript', but old documentation used case-insensitive values.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure modules with side-effects are separated into different chunks or mark them with sideEffects: false in package.json.","message":"AGGRESSIVE_BUNDLE mode hoists require() calls, which can cause out-of-order execution if polyfills or side-effects are interleaved.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set childCompilations: true or a custom function if child compilations need closure optimization.","message":"childCompilations defaults to false—plugins like html-webpack-plugin may not get optimized output.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.6.1':21 '20200830.0.0':30 '4':23,33 '5':80 'advanc':50 'aggress':47 'analysi':75 'babel':58 'branch':24 'bundl':48 'check':70 'closur':2,10,13,28,62 'closure-webpack-plugin':1 'code':67 'compat':77 'compil':11,29,63 'cross':73 'cross-modul':72 'dead':66 'elimin':68 'full':61 'googl':9,27 'google-closure-compil':26 'hoist':52 'includ':65 'integr':8 'java':39 'javascript':16,40,81 'librari':14 'minification/transpilation':46 'mode':43 'modul':51,74 'nativ':38 'offer':35 'optim':17,54,64 'platform':37 'plugin':4,7 'provid':60 'requir':25 'standard':44 'terserplugin':56 'three':36 'transpil':19 'two':42 'type':69 'unlik':55 'version':20 'webpack':3,6,22,32,79 'x':34","created_at":"2026-04-25T11:17:38.520954+00:00","updated_at":"2026-04-25T11:17:38.520954+00:00","problems":[{"fix":"Use `const ClosurePlugin = require('closure-webpack-plugin');`","cause":"Importing the plugin incorrectly (using default import instead of require).","error":"TypeError: ClosurePlugin is not a constructor"},{"fix":"Run `npm install --save-dev google-closure-compiler`","cause":"Required peer dependency not installed.","error":"Error: Cannot find module 'google-closure-compiler'"},{"fix":"Downgrade to webpack 4.x, or use an alternative plugin (e.g., terser-webpack-plugin) for webpack 5.","cause":"Using the plugin with webpack 5.","error":"Error: webpack version 5.x is not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/webpack-contrib/closure-webpack-plugin","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/closure-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","http-networking","web-framework","data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}