1.1.4 • Published 4 years ago

@m860/cerberus-babel-plugin-transform v1.1.4

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

cerberus-babel-plugin-transform

cerberus转换工具

Install

npm i -D @m860/cerberus-babel-plugin-transform

Usage

NOTE:默认情况下react,react-native会被替换

{
  "plugins": ["@cerberus/transform"]
}

如果需要替换自己的模块可以设置modules参数

{
  "plugins": [["@cerberus/transform",{"modules": ["dateformat"]}]]
}

NOTE: modules中设置的module名字和npm保持一致,在Cerberus库中导出的名字也必须一致。

Option

type Option={
    /**
     * 不需要被打包的公共模块
     */
    modules?:Array<string>,
    /**
     * 需要处理的资源文件的正则表达式,默认:/\.(gif|png|jpeg|jpg|svg)$/i 
     */
    resourceTest?:?RegExp
};

Examples

// input
import * as React from "react"
import React2 from "react"
import {memo,useState} from "react"
import {useRef as ur} from "react"
import {Text} from "react-native"
import df from "dateformat"
import {get as getPath} from "object-path"

// output
const React = $REACT$;
const React2 = $REACT$;
const memo = $REACT$.memo;
const useState = $REACT$.useState;
const ur = $REACT$.useRef;
const Text = $REACTNATIVE$.Text;
const df = $MODULES$["dateformat"];
const getPath = $MODULES$["object-path"].get;
1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago