babel-plugin-remove-unused-import
Version:
> Fork from babel-plugin-danger-remove-unused-import
57 lines (39 loc) • 1.13 kB
Markdown
> Fork from babel-plugin-danger-remove-unused-import
1. `visitor.Program.enter` -> `visitor.Program.exit`: make sure this plugin comes in after [minify-dead-code-elimination](https://babeljs.io/docs/en/babel-plugin-minify-dead-code-elimination).
2. remove import `binding.path.parentPath` if not referenced, ignoring side effects.
3. rename package to `babel-plugin-remove-unused-import`.
For shrinking the bundled javascript size :smile:
**Note: remove unused import is dangerous**
**because the imported package may have some side effects!**
```javascript
{
ignore: ['react']
}
```
```javascript
import React from 'react'
import Button from 'button'
import _ from 'lodash'
import moment from 'moment'
import { data } from '../some-where'
// ...
const a = {}
a.moment = <Button x={data} />
```
```diff
import React from 'react'
import Button from 'button'
- import _ from 'lodash'
- import moment from 'moment'
import {data} from '../some-where'
// ...
const a = {}
a.moment = <Button x={data} />
```
- [x] Supporting Scope