andrewimm / babel-plugin-remove-proptypes

Babel plugin for removing static declarations of React propTypes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-remove-proptypes

Babel plugin for removing static declarations of React propTypes on classes.

Input:

// MyComponent extends React.Component
MyComponent.propTypes = {
  someString: React.PropTypes.string.isRequired,
  someBoolean: React.PropTypes.bool
};

Output:

// Declaration is maintained in case other code references this propTypes object
MyComponent.propTypes = {};

The plugin can be used to remove PropTypes from production environments, where they have no effect.

Installation

$ npm install babel-plugin-remove-proptypes

Usage

Via .babelrc

{
  "plugins": ["remove-proptypes"]
}

Via CLI

$ babel --plugins remove-proptypes script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['remove-proptypes']
});

About

Babel plugin for removing static declarations of React propTypes


Languages

Language:JavaScript 100.0%