@m860/cerberus-babel-plugin-transform
v1.1.4
Published
cerberus转换工具
Downloads
8
Readme
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;