# @ampproject/rollup-plugin-closure-compiler

> Rollup + Google Closure Compiler

Latest version **0.27.0** (published 2021-08-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @ampproject/rollup-plugin-closure-compiler
pnpm add @ampproject/rollup-plugin-closure-compiler
yarn add @ampproject/rollup-plugin-closure-compiler
bun add @ampproject/rollup-plugin-closure-compiler
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.27.0 |
| Published | 2021-08-10 |
| First published | 2018-06-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 7 |
| Unpacked size | 200.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | The AMP HTML Authors |
| Maintainers | ampproject-admin, kristoferbaxter, jridgewell, choumx, amp-toolbox, fstanis, erwinmombay, samouri, caroqliu, rsimha, dvoytenko, patrickkettner, alanorozco, kdwan, ampprojectbot, esth |
| Keywords | rollup-plugin |

## Links

- npm: https://www.npmjs.com/package/@ampproject/rollup-plugin-closure-compiler
- Repository: https://github.com/ampproject/rollup-plugin-closure-compiler
- npm.io page: https://npm.io/package/@ampproject/rollup-plugin-closure-compiler

## Dependencies (7)

- [uuid](https://npm.io/package/uuid.md) 8.1.0
- [acorn](https://npm.io/package/acorn.md) 7.3.1
- [acorn-walk](https://npm.io/package/acorn-walk.md) 7.1.1
- [magic-string](https://npm.io/package/magic-string.md) 0.25.7
- [estree-walker](https://npm.io/package/estree-walker.md) 2.0.1
- [@ampproject/remapping](https://npm.io/package/@ampproject/remapping.md) 0.2.0
- [google-closure-compiler](https://npm.io/package/google-closure-compiler.md) 20210808.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.27.0 (latest) — 2021-08-10
- 0.9.0-beta.7 (beta) — 2018-11-12
- 0.5.0-alpha.2 (next) — 2018-07-16
- 0.26.0 — 2020-06-01
- 0.25.2 — 2020-04-13
- 0.25.1 — 2020-04-13
- 0.25.0 — 2020-04-13
- 0.24.0 — 2020-03-06
- 0.23.0 — 2020-03-02
- 0.22.2 — 2020-02-17
- 0.22.1 — 2020-02-17
- 0.22.0 — 2020-02-17
- 0.21.0 — 2020-02-03
- 0.20.0 — 2020-01-14
- 0.19.1 — 2020-01-10
- … 46 more at https://npm.io/package/@ampproject/rollup-plugin-closure-compiler/versions

## README

# rollup-plugin-closure-compiler

Leverage [Closure Compiler](https://developers.google.com/closure/compiler/) to minify and optimize JavaScript with [Rollup](https://rollupjs.org/guide/en).

Generally Closure Compiler will produce superior minification than other projects, but historically has been more difficult to use. The goal of this plugin is to reduce this friction.

## Installation

```bash
npm install @ampproject/rollup-plugin-closure-compiler --save-dev
```

## Usage

Invoke Closure Compiler from your Rollup configuration.

```js
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';

export default {
  input: 'main.js',
  output: {
    file: 'bundle.js',
    format: 'iife',
  },
  plugins: [
    compiler(),
  ],
}
```

If you would like to provide additional [flags and options](https://github.com/google/closure-compiler/wiki/Flags-and-Options) to Closure Compiler, pass them via key-value pairs.

```js
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';

export default {
  input: 'main.js',
  output: {
    file: 'bundle.js',
    format: 'iife',
  },
  plugins: [
    compiler({
      formatting: 'PRETTY_PRINT'
    }),
  ],
}
```

### Automatic Closure Configuration

This plugin will modify the enable the `assume_function_wrapper` output option for Closure Compiler when `es` format is specifed to Rollup. **Note**: This is overrideable via passed flags and options.

```js
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';

export default {
  input: 'main.js',
  output: {
    file: 'bundle.js',
    format: 'es',
  },
  plugins: [
    compiler(),
  ],
}
```

If your Rollup configuration outputs an IIFE format bundle with a specified name, this plugin will add an extern to ensure the name does not get mangled. **Note**: This is overrideable via passed flags and options.

```js
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';

export default {
  input: 'main.js',
  output: {
    file: 'bundle.js',
    format: 'iife',
    name: 'MyAwesomeThing'
  },
  plugins: [
    compiler(),
  ],
}
```

## Security disclosures

The AMP Project accepts responsible security disclosures through the [Google Application Security program](https://www.google.com/about/appsecurity/).

## Code of conduct

The AMP Project strives for a positive and growing project community that provides a safe environment for everyone.  All members, committers and volunteers in the community are required to act according to the [code of conduct](.github/CODE_OF_CONDUCT.md).

## License

rollup-plugin-closure-compiler is licensed under the [Apache License, Version 2.0](LICENSE).

---
_Source: https://npm.io/package/@ampproject/rollup-plugin-closure-compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
