{"id":13493697,"url":"https://github.com/webpack-contrib/closure-webpack-plugin","last_synced_at":"2025-05-16T06:04:19.044Z","repository":{"id":39562085,"uuid":"104812597","full_name":"webpack-contrib/closure-webpack-plugin","owner":"webpack-contrib","description":"Webpack Google Closure Compiler and Closure Library plugin - ","archived":false,"fork":false,"pushed_at":"2023-03-01T18:05:06.000Z","size":3154,"stargazers_count":436,"open_issues_count":28,"forks_count":60,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-16T06:03:29.093Z","etag":null,"topics":["closure-compiler","closure-library","google-closure-compiler","google-closure-library","optimization","treeshaking","uglifyjs","webpack"],"latest_commit_sha":null,"homepage":"https://developers.google.com/closure/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2017-09-25T23:35:16.000Z","updated_at":"2025-04-18T18:26:03.000Z","dependencies_parsed_at":"2023-02-08T05:17:14.688Z","dependency_job_id":"332ccda6-38c1-413e-b0c7-fb0e872b839c","html_url":"https://github.com/webpack-contrib/closure-webpack-plugin","commit_stats":{"total_commits":299,"total_committers":26,"mean_commits":11.5,"dds":"0.35451505016722407","last_synced_commit":"60cd06c4c0bab620fb78356070546bf926b6ad23"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fclosure-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fclosure-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fclosure-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fclosure-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-contrib","download_url":"https://codeload.github.com/webpack-contrib/closure-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478186,"owners_count":22077675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["closure-compiler","closure-library","google-closure-compiler","google-closure-library","optimization","treeshaking","uglifyjs","webpack"],"created_at":"2024-07-31T19:01:17.884Z","updated_at":"2025-05-16T06:04:18.991Z","avatar_url":"https://github.com/webpack-contrib.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# closure-webpack-plugin\n\n[![npm version](https://badge.fury.io/js/closure-webpack-plugin.svg)](https://badge.fury.io/js/closure-webpack-plugin)\n\nThis plugin supports the use of Google's Closure Tools with webpack.\n\n**Note: This is the webpack 4 branch.**\n\n[Closure-Compiler](https://developers.google.com/closure/compiler/) is a full optimizing compiler and transpiler.\nIt offers unmatched optimizations, provides type checking and can easily target transpilation to different versions of ECMASCRIPT.\n\n[Closure-Library](https://developers.google.com/closure/library/) is a utility library designed for full compatibility\nwith Closure-Compiler. \n\n## Older Versions\n\nFor webpack 3 support, see https://github.com/webpack-contrib/closure-webpack-plugin/tree/webpack-3\n\n## Install\n\nYou must install both the google-closure-compiler package as well as the closure-webpack-plugin.\n\n```\nnpm install --save-dev closure-webpack-plugin google-closure-compiler\n```\n\n## Usage example\n\n```js\nconst ClosurePlugin = require('closure-webpack-plugin');\n\nmodule.exports = {\n  optimization: {\n    minimizer: [\n      new ClosurePlugin({mode: 'STANDARD'}, {\n        // compiler flags here\n        //\n        // for debugging help, try these:\n        //\n        // formatting: 'PRETTY_PRINT'\n        // debug: true,\n        // renaming: false\n      })\n    ]\n  }\n};\n```\n\n## Options\n\n * **platform** - `native`, `java` or `javascript`. Controls which version to use of closure-compiler.\n     By default the plugin will attempt to automatically choose the fastest option available.\n    - `JAVASCRIPT` does not require the JVM to be installed. Not all flags are supported. \n    - `JAVA` utilizes the jvm. Utilizes multiple threads for parsing and results in faster compilation for large builds.\n    - `NATIVE` only available on linux or MacOS. Faster compilation times without requiring a JVM.\n * **mode** - `STANDARD` (default) or `AGGRESSIVE_BUNDLE`. Controls how the plugin utilizes the compiler.  \n    - `STANDARD` mode, closure-compiler is used as a direct replacement for other minifiers as well as most Babel transformations.  \n    - `AGGRESSIVE_BUNDLE` mode, the compiler performs additional optimizations of modules to produce a much smaller file\n * **childCompilations** - boolean or function. Defaults to `false`.\n  In order to decrease build times, this plugin by default only operates on the main compilation.\n  Plugins such as extract-text-plugin and html-webpack-plugin run as child compilations and\n  usually do not need transpilation or minification. You can enable this for all child compilations\n  by setting this option to `true`. For specific control, the option can be set to a function which\n  will be passed a compilation object.  \n  Example: `function(compilation) { return /html-webpack/.test(compilation.name); }`.\n * **output** - An object with either `filename` or `chunkfilename` properties. Used to override the\n  output file naming for a particular compilation. See https://webpack.js.org/configuration/output/\n  for details.\n * **test** - An optional string or regular expression to determine whether a chunk is included in the compilation\n * **extraCommandArgs** - Optional string or Array of strings to pass to the google-closure-compiler plugin.\n   Can be used to pass flags to the java process.\n  \n## Compiler Flags\n\nThe plugin controls several compiler flags. The following flags should not be used in any mode:\n\n * module_resolution\n * output_wrapper\n * dependency_mode\n * create_source_map\n * module\n * entry_point\n\n## Aggressive Bundle Mode\n\nIn this mode, the compiler rewrites CommonJS modules and hoists require calls. Some modules are not compatible with this type of rewriting. In particular, hoisting will cause the following code to execute out of order:\n\n```js\nconst foo = require('foo');\naddPolyfillToFoo(foo);\nconst bar = require('bar');\n```\n\nAggressive Bundle Mode utilizes a custom runtime in which modules within a chunk file are all included in the same scope.\nThis avoids [the cost of small modules](https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/).\n\nIn Aggressive Bundle Mode, a file can only appear in a single output chunk. Use the [Split Chunks Plugin](https://webpack.js.org/plugins/split-chunks-plugin/)\nto split duplicated files into a single output chunk. If a module is utilized by more than one chunk, the\nplugin will move it up to the first common parent to prevent code duplication.\n\nThe [concatenatedModules optimization](https://webpack.js.org/configuration/optimization/#optimization-concatenatemodules)\nis not compatible with this mode since Closure-Compiler performs an equivalent optimization).\nThe plugin will emit a warning if this optimization is not disabled.\n\n## Multiple Output Languages\n\nYou can add the plugin multiple times. This easily allows you to target multiple output languages.\nUse `ECMASCRIPT_2015` for modern browsers and `ECMASCRIPT5` for older browsers.\n\nUse the `output` option to change the filenames of specific plugin instances.\n\nUse `\u003cscript type=\"module\" src=\"es6_out_path.js\"\u003e` to target modern browsers and\n`\u003cscript nomodule src=\"es5_out_path.js\"\u003e` for older browsers.\n\nSee the [es5 and es6 output demo](https://github.com/webpack-contrib/closure-webpack-plugin/tree/master/demo/es5-and-es6)\nfor an example.\n\n## Other tips for Use\n * Don't use babel at the same time - closure-compiler is also a transpiler.\n   If you need [features not yet supported](https://github.com/google/closure-compiler/wiki/ECMAScript6) by closure-compiler, have babel\n   only target those features. Closure Compiler can transpile async/await - you don't need babel for that functionality either.\n\n# Closure Library Plugin\nIn order for webpack to recognize `goog.require`, `goog.provide`, `goog.module` and related primitives,\na separate plugin is shipped.\n\n```js\nconst ClosurePlugin = require('closure-webpack-plugin');\n\nmodule.exports = {\n  plugins: [\n    new ClosurePlugin.LibraryPlugin({\n      closureLibraryBase: require.resolve(\n        'google-closure-library/closure/goog/base'\n      ),\n      deps: [\n        require.resolve('google-closure-library/closure/goog/deps'),\n        './public/deps.js',\n      ],\n    })\n  ]\n};\n```\nThe plugin adds extra functionality to support using Closure Library without Closure Compiler.\nThis is typically used during development mode. When the webpack mode is `production`,\nonly dependency information is provided to webpack as Closure Compiler will natively recognize\nthe Closure Library primitives.\n\nThe Closure Library Plugin is only compatible with the `AGGRESSIVE_BUNDLE` mode of the Closure-Compiler\nwebpack plugin.\n\n## Options\n\n * **closureLibraryBase** - (optional) string. Path to the base.js file in Closure-Library.\n * **deps** - (optional) string or Array. Closures style dependency mappings. Typically generated by the\n   [depswriter.py script](https://developers.google.com/closure/library/docs/depswriter) included with Closure-Library.\n * **extraDeps** - (optional) Object. Mapping of namespace to file path for closure-library provided namespaces.\n   \n   \n\u003ch2 align=\"center\"\u003eMaintainers\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/ChadKillingsworth\"\u003e\n          \u003cimg width=\"150\" alt=\"\" height=\"150\" src=\"https://avatars.githubusercontent.com/u/1247639?v=3\"\u003e\n          \u003c/br\u003e\n          Chad Killingsworth\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/d3viant0ne\"\u003e\n          \u003cimg width=\"150\" alt=\"\" height=\"150\" src=\"https://avatars.githubusercontent.com/u/8420490?v=3\"\u003e\n          \u003c/br\u003e\n          Joshua Wiens\n        \u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fclosure-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-contrib%2Fclosure-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fclosure-webpack-plugin/lists"}