angular
angular copied to clipboard
Report unused standalone imports
Which @angular/* package(s) are relevant/related to the feature request?
common
Description
With the popularity of standalone components (pipes/directives), powered by Angular as well, there is a possibility that some components will be unused in templates while still imported by parent component, and so will increase bundle
Proposed solution
Report during the build that some.pipe/directive is imported but not used. It can be controlled via angulqrCompilerOptions of tsconfig
Alternatives considered
Nothing
It is in the works :-)
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
@pkozlowski-opensource Is this still in the works, or should we take @angular-robot's comment to mean that this won't be done?
@MaximSagan I've removed the angular-robot comment - this is something we would love to address.
@pkozlowski-opensource do you know the statistics of issues which pass votes? Seems like 20 votes is too much...
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
Seems like script for bot wasn't tested enough;)
Seems like script for bot wasn't tested enough;)
@pkozlowski-opensource
Will this also be possible for NgModules
?
Any news about this cool feature ? :)
I want to reopen the pollling! I wasn't using Stand-Alone components until now and now I really want to have an auto-cleanup of unused components. :)
This seems like it should be a pretty major thing now, especially with more and more people moving to standalone components?
So easy to end up with left-over imports hanging around that aren't needed anymore - especially if/when code gets copy-pasted from one component to another - and no easy way to auto-detect these, unless there is some other way I don't know about?
It's also quite difficult to do manually - especially if you have a lot of components, and especially since the imports and the templates that use them are usually in different files.
This seems like it should be a pretty major thing now, especially with more and more people moving to standalone components?
So easy to end up with left-over imports hanging around that aren't needed anymore - especially if/when code gets copy-pasted from one component to another - and no easy way to auto-detect these, unless there is some other way I don't know about?
It's also quite difficult to do manually - especially if you have a lot of components, and especially since the imports and the templates that use them are usually in different files.
This problem is not new to standalone; NgModules have always had those same challenges.
This seems like it should be a pretty major thing now, especially with more and more people moving to standalone components? So easy to end up with left-over imports hanging around that aren't needed anymore - especially if/when code gets copy-pasted from one component to another - and no easy way to auto-detect these, unless there is some other way I don't know about? It's also quite difficult to do manually - especially if you have a lot of components, and especially since the imports and the templates that use them are usually in different files.
This problem is not new to standalone; NgModules have always had those same challenges.
Yes but this one is more easily solvable it seems. Also not an excuse. :)
Yes, I would also like to mention that this is getting more important because of standalone components being used by more people. Here in my company, as we like to don't have imports that we do actually not need we have an additional code review step to check if the components imported by a component are actually used. That takes some time and I guess in terms of dev experience it would be great to instantly know if an import is used or not. This becomes important especially in projects where there is some continues refactoring going on. We had that for example when we migrated components to use the standalone paradigm and by that we also tried to refactor some parts, that ended up in some imports not needed anymore and it was some effort to find these imports...
So to sum up, I would also vote for this issue from the current point of view.
standalone
is default in Angular v17 now, so this warning would be convenient
Are there any updates?
4/13/2024
Definitively a MUST HAVE these days with Angular 17+ Come on!
@pkozlowski-opensource Any news about this?
Any updates on this?
This issue is annoying, because it possibly increases the compile time and bundle size. But the other side of this issue, where an import is missing, as reported in #46351, is much more critical, because it can lead to runtime "missing behavior" without any errors or warnings, neither at build time or at runtime.
I think this is an important feature for projects. It does not necessarily need to be in simple compilation (to maintain performance) => This could be an option or an specific command.
Upvote