1.1.0 • Published 5 years ago

babel-plugin-demand v1.1.0

Weekly downloads
9
License
ISC
Repository
github
Last release
5 years ago

babel-plugin-demand

用于公共 js 库按需加载的babel插件

NPM version Build Status

Install

npm i babel-plugin-demand -D

Usage

.babelrc 或者 babel-loader 文件中配置

{
  "plugins": [
    [
      "demand", {
        packageName: 'xx-sdk',
        redirect: 'lib'
        // ...options
      }
    ]
  ]
}

Example

import { foo } from 'xx-sdk'
foo()

上述代码会被转为

import _foo from 'xx-sdk/lib/foo'
_foo()

options

参数名称类型含义是否必填默认值
packageNameStringjs 包的名字
redirectString函数所在的目录'lib'
moreRedirectArrayredirect目录不存在时,自动检索该数组中的路径[]
camel2DashBoolean驼峰文件名是否需要转为'-'连接false

more

  • 编译过程中 ast 的 types 可以参考doc文件下的 ast-types
1.1.0

5 years ago

1.0.3

5 years ago

1.0.2-1

5 years ago

1.0.2

5 years ago

1.0.1-3

5 years ago

1.0.1-2

5 years ago

1.0.1-1

5 years ago

1.0.1

5 years ago

1.0.0-2

5 years ago

1.0.0-0

5 years ago

1.0.0

5 years ago