You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing the same behavior. I think one cause of the unused variable not being removed is that if it contains any function calls the minifier won't remove it in case there are side-effects to the function calls.
I have noticed the additional problem that when using the removeImport option, the imports are also not removed since they are still referenced in the propTypes variable. So even if the minifier was removing the unused variable, it will not remove the imports.
I think this plugin should be enhanced so that it transforms code that looks like this:
This is a request for a feature similar to #75.
Pulling this comment out from #75 for visibility:
I'm seeing the same behavior. I think one cause of the unused variable not being removed is that if it contains any function calls the minifier won't remove it in case there are side-effects to the function calls.
I have noticed the additional problem that when using the
removeImport
option, the imports are also not removed since they are still referenced in the propTypes variable. So even if the minifier was removing the unused variable, it will not remove the imports.I think this plugin should be enhanced so that it transforms code that looks like this:
into this:
At least for the simple case when it can be determined that the variable is no longer used.
Additionally, we often wrap our propTypes in a function when assigning it to the component, like this:
So the unused variable detection would ideally be smart enough to transform the above to:
What do you think? Is it worth taking a swing at this?
The text was updated successfully, but these errors were encountered: