Negatory. Postpone Mission.
    Wondering what’s next for npm?Check out our public roadmap! »

    babel-plugin-remove-unused-import

    2.1.1 • Public • Published

    babel-plugin-remove-unused-import

    Fork from babel-plugin-danger-remove-unused-import

    Fork Changes

    1. visitor.Program.enter -> visitor.Program.exit: make sure this plugin comes in after 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 😄

    Note: remove unused import is dangerous because the imported package may have some side effects!

    Option

    {
      ignore: ['react']
    }

    Input

    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} />

    Output

    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} />

    Todo

    • [x] Supporting Scope

    Install

    npm i babel-plugin-remove-unused-import

    DownloadsWeekly Downloads

    7

    Version

    2.1.1

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar