npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

babel-plugin-inflow

v1.0.0

Published

Babel code injection plugin

Downloads

4

Readme

babel-plugin-inflow

Babel code injection plugin.It can be used together with burying tools. To avoid damaging the integrity of code structure, you can also do different embedding actions for different environments or modes.This plugin supports babel6 and babel7.And supports react babel代码注入插件。可结合埋点工具一起使用。避免破坏代码结构完整性,也可以针对不同环境或者模式做不同埋点动作。此插件支持babel6以及babel7。并且支持react

Installation

npm install --save-dev babel-plugin-inflow

Now edit your .babelrc to include babel-plugin-inflow.

{
  "presets": ["es2015", "stage-0"],
  "plugins": ["babel-plugin-inflow"],
}

example

/*@inflow inFlowfun(num)*/
const afun=(num)=>{
    console.log('afun',num)
}
//@inflow inFlowfun(num)
function bfun(num){
    console.log('bfun',num)
}

class Index extends React.Component {
  /*@inflow test3()*/  
  constructor(props) {
    super(props);
    this.state = {
      user: '',
      password: '',
    };
  }
  /*@inflow test4()*/  
  testfun(){
    console.log(1)
  }
  /*@inflow test5()*/  
  testProp=()=>{
    console.log(1)
  }  
}  

after using babel-plugin-inflow, the above code is translated into 在使用了babel-plugin-inflow后,以上代码的被翻译成了

const afun=(num)=>{
    inFlowfun(num)
    console.log('afun',num)
}
function bfun(num){
    inFlowfun(num)
    console.log('bfun',num)
}

class Index extends React.Component {
  constructor(props) {
    test3()
    super(props);
    this.state = {
      user: '',
      password: '',
    };
  }
  testfun(){
    test4()
    console.log(1)
  } 
  testProp=()=>{
    test5()
    console.log(1)
  }  
}  

configuration parameter

The. Inflow file is at the same level as. Babelrc. The specific parameters are as follows .inflow文件和.babelrc同一层级。具体参数如下

{
    "key":"inflow", 
    "debug":[{      
       "key":"process.env.NODE_ENV",
       "value":"develop",
       "debugKey":"inFlowfun"
    }]
}

Inflow indicates the flag bit of buried point identification method, and inflow is the default value inflow 表示识别埋点方法标志位,inflow为默认值

The corresponding content in debug can be understood as if(process.env.NODE_ENV=="develop"){ replace the keyword zhe with console.log. If the debugkey is empty or does not exist, then if the condition of if is met, the point will not be buried} debug中对应的内容可以理解为, if(process.env.NODE_ENV=="develop"){ 将关键字zhuge替换为console.log,如果debugkey为空或者不存在,则满足if的条件时不埋点}

If. Inflow is configured as above, the above example will be translated as follows 如果.inflow配置如上,则以上的例子会被翻译为如下:

const afun=(num)=>{
    if(process.env.NODE_ENV=="develop"){
        console.log(num)
    } 
    else{
        inFlowfun(num)
    }
    console.log('afun',num)
}

License

MIT