Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/tgxhx/babel-plugin-webpack-async-module-name
- Owner: tgxhx
- Created: 2018-04-28T03:42:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T20:36:58.000Z (about 2 years ago)
- Last Synced: 2024-10-03T08:06:17.630Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 109 KB
- Stars: 19
- Watchers: 1
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
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)