babel-plugin-transform-react-remove-prop-types icon indicating copy to clipboard operation
babel-plugin-transform-react-remove-prop-types copied to clipboard

Support for configure wrap condition

Open supersnager opened this issue 5 years ago • 4 comments

Sometimes you may want to remove propTypes for production build, but sometimes not. For example when your library is imported in storybook, you want not to remove propTypes, because storybook reads it to show in docs page.

I think, that plugin should support this case - condition string should be configurable.

In storybook scenario wrap condition might look like this:

if (process.env.NODE_ENV !== "production" || process.env.NOT_REMOVE_PROP_TYPES) {

supersnager avatar Apr 04 '20 09:04 supersnager

I think this can be accomplished by using BABEL_ENV

On Sat, Apr 4, 2020, 4:25 AM Super Snager [email protected] wrote:

Sometimes you may want to remove propTypes for production build, but sometimes not. For example when your library is imported in storybook, you want not to remove propTypes, because storybook reads it to show in docs page.

I think, that plugin should support this case - condition string should be configurable.

In storybook scenario wrap condition might look like this:

if (process.env.NODE_ENV !== "production" || process.env.NOT_REMOVE_PROP_TYPES) {

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/issues/191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPXTX77PUSBIW6TOAO72DRK34HPANCNFSM4L5YWFDQ .

lencioni avatar Apr 04 '20 11:04 lencioni

@lencioni How? Can you explain it further?

supersnager avatar Apr 04 '20 15:04 supersnager

I think you could define a storybook env in your Babel config that doesn't include this plugin, and then start storybook with the BABEL_ENV env var set to match.

On Sat, Apr 4, 2020, 10:29 AM Super Snager [email protected] wrote:

@lencioni https://github.com/lencioni How? Can you explain it further?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/issues/191#issuecomment-609045238, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPXTRZ36AKNEJQIEDKURDRK5G33ANCNFSM4L5YWFDQ .

lencioni avatar Apr 04 '20 15:04 lencioni

@lencioni It is not possible to do it in this way. Library is dependency in storybook, is already built and has wrapped prop types:

if (process.env.NODE_ENV !== "production" ) {

supersnager avatar Apr 05 '20 09:04 supersnager