Skip to content

tgxhx/babel-plugin-webpack-async-module-name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Downloads

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

npm i -D babel-plugin-webpack-async-module-name

Test

npm run test

Usage

Add the plugin to babelrc:

{
  "plugins": [
    "webpack-async-module-name"
  ]
}

Use in code:

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:

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

About

Babel plugin, name the webpack dynamic modules.

Resources

Stars

Watchers

Forks

Packages

No packages published