# rollup-plugin-auto-external

> Rollup plugin to automatically exclude package.json dependencies and peerDependencies from your bundle

Latest version **2.0.0** (published 2018-07-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-auto-external
pnpm add rollup-plugin-auto-external
yarn add rollup-plugin-auto-external
bun add rollup-plugin-auto-external
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-07-30 |
| First published | 2017-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/rollup-plugin-auto-external) |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 4 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Author | Steven Benisek |
| Maintainers | stevenbenisek |
| Keywords | rollup, plugin, external, auto, dependencies, peerDependencies |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-auto-external
- Repository: https://github.com/stevenbenisek/rollup-plugin-auto-external
- Issues: https://github.com/stevenbenisek/rollup-plugin-auto-external/issues
- npm.io page: https://npm.io/package/rollup-plugin-auto-external

## Dependencies (4)

- [semver](https://npm.io/package/semver.md) ^5.5.0
- [builtins](https://npm.io/package/builtins.md) ^2.0.0
- [read-pkg](https://npm.io/package/read-pkg.md) ^3.0.0
- [safe-resolve](https://npm.io/package/safe-resolve.md) ^1.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

- 2.0.0 (latest) — 2018-07-30
- 3.0.0-alpha.0 (alpha) — 2019-03-03
- 1.2.0 — 2018-02-08
- 1.1.0 — 2018-01-29
- 1.0.1 — 2018-01-19
- 1.0.0 — 2017-07-31

## README

# rollup-plugin-auto-external

[![Build Status](https://travis-ci.org/stevenbenisek/rollup-plugin-auto-external.svg?branch=master)](https://travis-ci.org/stevenbenisek/rollup-plugin-auto-external)

> [Rollup](https://rollupjs.org/) plugin to automatically exclude package.json dependencies and peerDependencies from your bundle.

## Install

```bash
npm install --save-dev rollup-plugin-auto-external
```

## Usage

##### Example `rollup.config.js`

```js
import autoExternal from 'rollup-plugin-auto-external';

export default {
  input: 'index.js',
  plugins: [autoExternal()],
};
```

##### Example `rollup.config.js` with options

```js
import path from 'path';
import autoExternal from 'rollup-plugin-auto-external';

export default {
  input: 'index.js',
  plugins: [
    autoExternal({
      builtins: false,
      dependencies: true,
      packagePath: path.resolve('./packages/module/package.json'),
      peerDependencies: false,
    }),
  ],
};
```

##### Example `rollup.config.js` with [external](https://github.com/rollup/rollup/wiki/JavaScript-API#external)

`rollup-plugin-auto-external` does not overwrite the [external](https://github.com/rollup/rollup/wiki/JavaScript-API#external) option. The two can happily coexist.

```js
import autoExternal from 'rollup-plugin-auto-external';

export default {
  input: 'index.js',
  external: id => id.includes('babel-runtime'),
  plugins: [autoExternal()],
};
```

##### Example `rollup.config.js` with per format options

```js
import autoExternal from 'rollup-plugin-auto-external';

export default ['es', 'umd'].map(format => ({
  input: 'index.js',
  plugins: [
    autoExternal({
      dependencies: format === 'es',
    }),
  ],
}));
```

### Options

#### `builtins`

`boolean`|`string`: defaults to `true`. Add all Node.js builtin modules (in the running version) as externals. Specify a `string` value (e.g., `'6.0.0'`) to add all builtin modules for a _specific version_ of Node.js.

Rollup will complain if `builtins` is present, and the build target is a browser. You may want [rollup-plugin-node-builtins](https://npm.im/package/rollup-plugin-node-builtins).

#### `dependencies`

`boolean`: defaults to `true`.

#### `packagePath`

`string`: defaults to `process.cwd()`. Path to a package.json file or its directory.

#### `peerDependencies`

`boolean`: defaults to `true`.

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