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

Use regex.test(str) instead of str.match(regex) #152

Closed lencioni closed 5 years ago

lencioni commented 6 years ago

This method returns a boolean so it should be faster and more memory efficient.

In order to make this work, I needed to remove the global flag from the regexes, because that makes the regexes mutable when run multiple times. Since these are only used to test for any match, and not for any matching groups or in any other way, we don't need this flag.

cc @ljharb

oliviertassinari commented 5 years ago

@lencioni Well done 👍