# babel-plugin-filter-imports

> A babel transform for filtering out imports

Latest version **4.0.0** (published 2019-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-filter-imports
pnpm add babel-plugin-filter-imports
yarn add babel-plugin-filter-imports
bun add babel-plugin-filter-imports
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2019-11-20 |
| First published | 2015-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 2 |
| Unpacked size | 27.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Martin Muñoz |
| Maintainers | ember-cli, layershifter, mmun, rwjblue, stefanpenner |
| Keywords | babel, babel-plugin |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-filter-imports
- Repository: https://github.com/ember-cli/babel-plugin-filter-imports
- Issues: https://github.com/ember-cli/babel-plugin-filter-imports/issues
- npm.io page: https://npm.io/package/babel-plugin-filter-imports

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.7.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2019-11-20
- 3.0.0 — 2019-04-12
- 2.0.4 — 2018-11-10
- 2.0.3 — 2018-09-28
- 2.0.2 — 2018-09-10
- 2.0.0 — 2018-04-30
- 1.1.2 — 2018-04-30
- 1.1.1 — 2017-11-29
- 1.1.0 — 2017-10-08
- 1.0.4 — 2017-09-27
- 1.0.3 — 2017-09-08
- 1.0.2 — 2017-09-08
- 1.0.0 — 2017-09-08
- 0.3.1 — 2017-03-14
- 0.3.0 — 2016-08-25
- … 3 more at https://npm.io/package/babel-plugin-filter-imports/versions

## README

# babel-plugin-filter-imports

[![Build Status](https://travis-ci.org/ember-cli/babel-plugin-filter-imports.svg?branch=master)](https://travis-ci.org/ember-cli/babel-plugin-filter-imports)
[![npm](https://img.shields.io/npm/v/babel-plugin-filter-imports.svg?style=flat)](https://www.npmjs.com/package/babel-plugin-filter-imports)
[![Greenkeeper badge](https://badges.greenkeeper.io/ember-cli/babel-plugin-filter-imports.svg)](https://greenkeeper.io/)

This babel plugin is used to removed references to imports within a module. This can be useful for removing debugging statements when doing a production build of your code. It is often used in conjunction with other tools like Uglify that perform dead code elimination.

## Installation

```sh
$ yarn add --dev babel-plugin-filter-imports
```

*This plugin is for Babel 7. If you need to support:*
- *Babel 6 use the [babel6](https://github.com/ember-cli/babel-plugin-filter-imports/tree/babel6) branch*
- *Babel 5 use the [v0.2.x](https://github.com/ember-cli/babel-plugin-filter-imports/tree/v0.2.x) branch*


## Example

Given the `.babelrc`

```json
{
  "plugins": [["filter-imports", {
    "imports": {
      "debugging-tools": [ "warn" ]
    }
  }]]
}
```

the module

```js
import { warn } from 'debugging-tools';

function join(args, sep) {
  if (arguments.length > 2) {
    warn("join expects at most 2 arguments");
  }
  return args.join(sep);
}
```

will be transformed to

```js
function join(args, sep) {
  if (arguments.length > 2) {
  }
  return args.join(sep);
}
```

## Configuration

- `options[keepImports]` `[Boolean]`: An flag that indicates imports removal from header.
- `options[imports]` `[Object]`: An object whose keys are names of modules.
- `options[imports][moduleName]` `[String]`: An array of names of imports from `moduleName` to be removed. You can include `'default'` for default export and `'*'` for a namespace export.

## Upgrade to `1.x`/`2.x`

There were breaking changes in the plugin configuration, you must update it to work correctly.

##### Before `1.x`

```json
{
  "plugins": [["filter-imports", {
    "debugging-tools": [ "warn" ]
  }]]
}
```

##### After

```json
{
  "plugins": [["filter-imports", {
    "imports": {
      "debugging-tools": [ "warn" ]
    }
  }]]
}
```

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