Nobody Pays (for) Magazines

    babel-plugin-change-import

    0.2.0 • Public • Published

    babel-plugin-change-import Build Status

    This plugin is a transform to remove unused library dependencies, without forcing the user to cherry pick import manually. This lets you use libraries naturally without worrying about bundling parts you're not using.

    Installation

    using npm

    npm install babel-plugin-change-import -S

    or via yarn

    yarn add babel-plugin-change-import -S

    Example

    .babelrc (Recommended)
    {
      "plugins": [
          ["change-import", {
            "libraryName": "@company/ds",
            "modulePath": "@company/ds/components"
          }]
        ]
    }

    Transforms

    import { Button, Input, Text} from '@company/ds'

    to

    import Button from '@company/ds/components/Button'
    import Input from '@company/ds/components/Input'
    import Text from '@company/ds/components/Text'

    Options

    You can to specific your imports

    1. "specific"

    .babelrc
    {
      "plugins": [
          ["change-import", {
            "libraryName": "@company/ds",
            "modulePath": "@company/ds/components",
            "specific": {
                "configure": "@mobi/ds/configure",
            },
          }]
        ]
    }

    Transforms

    import { Button, configure } from '@company/ds'

    to

    import Button from '@company/ds/components/Button'
    import configure from '@company/ds/configure'

    2. "specificDestructuring"

    .babelrc
    {
      "plugins": [
          ["change-import", {
            "libraryName": "@company/ds",
            "modulePath": "@company/ds/components",
            "specificDestructuring": {
                "useAlert": "@mobi/ds/components/Alert",
            },
          }]
        ]
    }

    Transforms

    import { Button, useAlert } from '@company/ds'

    to

    import Button from '@company/ds/components/Button'
    import { useAlert } from '@company/ds/components/Alert'

    License

    MIT

    Keywords

    none

    Install

    npm i babel-plugin-change-import

    DownloadsWeekly Downloads

    839

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    6.23 kB

    Total Files

    5

    Last publish

    Collaborators

    • victorvoid