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
It would be nice to have an option that is similar to additionalLibraries that could be used to remove these imports. Perhaps the option could take a regex pattern or glob pattern?
The text was updated successfully, but these errors were encountered:
@lencioni What makes you think this plugin can be more efficient at removing dead code than another tool specifically tailored for it? I mean, if a dead code prunner can't remove some code, what enable us, from an architectural point of view, to do it?
We definitely want people to have a bundle prop-types free when using a JavaScript minifier + this plugin. I have been experiencing the same issue in the past. I have been using hacks like this one to save bundle size.
Although the minification of the custom propType code itself, as you linked to, is useful, I would ideally like to remove the import as well in the same way that the additionalLibraries option works, not only to save bundle size, but also to improve runtime speed a little by removing the overhead of an additional module everywhere.
I think a JavaScript minifier will not remove the unused import because it doesn't know that the import is free of side-effects. Having a way to opt in related imports in this plugin would be useful.
Another thought that occurs to me is that this could perhaps be automatically detected. When removing the propTypes, it could detect any newly unused imports and remove them as well.
I don't think that it should be the default behavior given the potential side effects you mentioned, at the exception of prop-types that is side-effect free, so we can do it automatically.
Still, I agree. We have the opportunity with this plugin to efficiently remove the imports.
We have some packages that have some custom propTypes defined in modules in that package itself. For example:
These custom propTypes can also be imported by consuming packages via deep imports:
It would be nice to have an option that is similar to
additionalLibraries
that could be used to remove these imports. Perhaps the option could take a regex pattern or glob pattern?The text was updated successfully, but these errors were encountered: