# babel-plugin-imports

> ES6 模块导入规则转换，支持“命名导入”、“默认导入”和“命名空间导入”三种规则，并支持一对多转换。

Latest version **0.2.4** (published 2018-01-08) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2018-01-08 |
| First published | 2016-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | pfdnpm |
| Maintainers | pfdnpm |
| Keywords | babel, plugin, import, module, transform |

## Links

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

## 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

- 0.2.4 (latest) — 2018-01-08
- 0.2.3 — 2016-12-26
- 0.2.2 — 2016-12-23
- 0.2.1 — 2016-12-23
- 0.2.0 — 2016-12-22
- 0.1.0 — 2016-12-21

## README

# babel-plugin-imports

[![npm version](https://badge.fury.io/js/babel-plugin-imports.svg)](http://badge.fury.io/js/babel-plugin-imports) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)]()

ES6 模块导入规则转换，支持“命名导入”、“默认导入”和“命名空间导入”三种规则，并支持一对多转换。  
如：  
import { importedName as localName } from 'moduleName'; => import { newImportedName as newLocalName } from 'newModuleName';  
import localName from 'moduleName'; => import { default as newLocalName } from 'newModuleName';  
import * as localName from 'moduleName'; => import newLocalName from 'newModuleName';

## Installation

``` bash
npm install --save-dev babel-plugin-imports
```

## Usage

转换规则可以直接在 .babelrc 文件中配置，也可以在 ruleExtend.js 文件中配置。  

Rules:  
[.babelrc 配置示例](.babelrc)  
[ruleExtend.js 配置示例](ruleExtend.js)  

Before:  
``` javascript
// ImportSpecifier
import { importedName_1 as localName_1, importedName_2 } from 'moduleName';

// ImportDefaultSpecifier
import localName_3 from 'moduleName';

// ImportNamespaceSpecifier
import * as localName_4 from 'moduleName';
```

After:  
``` javascript
// ImportSpecifier
import localName_1 from 'moduleName/path/importedName_1';
import importedName_2 from 'moduleName/path/importedName_2';

// ImportDefaultSpecifier

import { default as localName_3 } from 'moduleName/path/';

// ImportNamespaceSpecifier

import localName_4 from 'moduleName/path/';
```

## License

This project is licensed under MIT.

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