wssgcg1213 / babel-plugin-replace-identifiers

babel-plugin-replace-identifiers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-replace-identifiers

replace-identifiers

It replace an Identifier to another Identifier.

If you want to replace an Identifier to a string literal(LVal), you can see this: babel-plugin-inline-replace-variables

Example

.babelrc

{
  "plugins": [
    ["replace-identifiers", {
      "React": "Rx"
    }]
  ]
}

In

React.createElement('foo', bar, 'React', React);

Out

Rx.createElement('foo', bar, 'React', Rx);

Installation

$ npm install babel-plugin-replace-identifiers

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": [["replace-identifiers", {
    "foo": "bar",
    "hello": "world"
  }]]
}

Via CLI

$ babel --plugins replace-identifiers script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["replace-identifiers"]
});

About

babel-plugin-replace-identifiers


Languages

Language:JavaScript 100.0%