babel-plugin-change-import
v0.2.0
Published
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.
Downloads
705
Readme
babel-plugin-change-import
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'