🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@m860/cerberus-babel-plugin-transform

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@m860/cerberus-babel-plugin-transform

cerberus转换工具

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

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;

FAQs

Package last updated on 29 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts