1.0.3 • Published 3 years ago

babel-plugin-tree-shaking v1.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

@dian/babel-plugin-tree-shaking

用于转换 Dian api 为模块化引用,以达到 tree-shaking 的目的。

Install

yarn add -D @dian/babel-plugin-tree-shaking --registry=https://npm.dian.so

Example

import Dian from '@dian/taro'
Dian.request(...)

会转换为:

import { request as _request } from '@dian/taro'
_request(...)

Usage

// babel.config.js

module.exports = {
  plugins: [
    [
      '@dian/babel-plugin-tree-shaking',
      {
        // 可使用通配符进行配置,eg: '@dian/*' '@a/*' 等
        packageName: '@dian/*'
      }
    ]
  ]
}

Attention

  • 因没有做api支持度校验,所以只要使用Dian.xxx的都会进行转换,可能存在报错

Todo

  • 支持api支持校验
  • 支持多个库 ✔️
  • unit test