Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tgxhx/babel-plugin-webpack-async-module-name

Babel plugin, name the webpack dynamic modules.
https://github.com/tgxhx/babel-plugin-webpack-async-module-name

Last synced: 3 months ago
JSON representation

Babel plugin, name the webpack dynamic modules.

Awesome Lists containing this project

README

        

[![Downloads](https://img.shields.io/npm/dm/babel-plugin-webpack-async-module-name.svg)](https://www.npmjs.com/package/babel-plugin-webpack-async-module-name)

# babel-plugin-webpack-async-module-name

> This plugin use custom identifier to named webpack dynamic import modules, supports single or multiple modules.
>
> Support Babel 6 and Babel 7.

## Installation
``` shell
npm i -D babel-plugin-webpack-async-module-name
```

## Test
``` shell
npm run test
```

## Usage

Add the plugin to [babelrc](https://babeljs.io/docs/usage/babelrc/):
``` json
{
"plugins": [
"webpack-async-module-name"
]
}
```

Use in code:

``` javascript
importName('./a.js')

importName('./a.js', 'name-a')

importName(['./a.js', './b.js'])

importName(['./a.js', './b.js'], 'name-a-b')
```

It will be transformed to:

``` javascript
import('./a.js');

import( /*webpackChunkName: 'name-a'*/'./a.js');

Promise.all([import('./a.js'), import('./b.js')]);

Promise.all([import( /*webpackChunkName: 'name-a-b'*/'./a.js'), import( /*webpackChunkName: 'name-a-b'*/'./b.js')]);
```

## License
[MIT](https://opensource.org/licenses/mit-license.php)