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

fix: more aggressive remove-proptypes exploration #108

Closed oliviertassinari closed 7 years ago

oliviertassinari commented 7 years ago

Closes #106.

LeonardoGentile commented 7 years ago

👍 thanks, is this released on npm already?

oliviertassinari commented 7 years ago

It's on npm now.

LeonardoGentile commented 7 years ago

@oliviertassinari I've just installed and retried the use cases listed on #106 and nothing changed from my perspective. The propTypes mentioned in the issue keeps on living in the compiled code, they are never removed, also the import is never removed as well

LeonardoGentile commented 7 years ago

Also adding the special comments for helping the plugin has no effect at all:

BaseLink.propTypes[storeName] /* remove-proptypes */ = PropTypes.object;
oliviertassinari commented 7 years ago

I'm not supporting that pattern, have a look at the test case.

oliviertassinari commented 7 years ago

also the import is never removed as well

From my understanding of the situation, you are shipping a library, you need to keep them so users get warnings in dev mode. Have a look at the test case, I think that it's what you need, but not what you want (guess).

LeonardoGentile commented 7 years ago

👍 thanks for the suggestion, I wasn't aware of es6 object dynamic keys, that solve the problem I was trying to fix.

I will ship the PropTypes then as you suggested.

I've made a local test with your suggestion and I can confirm that it fixes the problem, all the proptypes are removed as well as the import.

Thanks 👍

oliviertassinari commented 7 years ago

Awesome 😄 , unless you noticed it, the test case is using the wrap mode. I would encourage you doing the same. Here the docs.