oliviertassinari / babel-plugin-transform-react-remove-prop-types

Remove unnecessary React propTypes from the production build. :balloon:
MIT License
897 stars 61 forks source link

Support createReactClass alternatives via config #176

Closed tquetano-netflix closed 5 years ago

tquetano-netflix commented 5 years ago

Currently, when using the legacy create-react-class package, this plugin will only apply code removal if the name of the method doing the creation is createReactClass based on this line of source code, and this lines up with the documentation for React. That said, it should be fairly easy to allow configuration of this value by the options for the plugin (with the current createReactClass as default), and for our codebase where just createClass is used this would save us a lot of reconciliation time.

I can create a PR if you are open to this addition, this issue is just testing the waters in this regard.

oliviertassinari commented 5 years ago

@tquetano-netflix Sure, I have no objection with an option 👍 .

tquetano-netflix commented 5 years ago

@oliviertassinari sweet, once I get a little time I'll throw a PR up.

oliviertassinari commented 5 years ago

Would #163 help?

tquetano-netflix commented 5 years ago

EDIT: Wait I misread the PR you reference ... I think both are beneficial in slightly different ways. #163 allows for when createClass is on the React object, whereas my change allows for const createClass = require('create-react-class');.