question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tree shakable component providers

See original GitHub issue

🚀 feature request

Relevant Package

@angular/core

Description

I can tree shake components/directives, and module providers.

I want to tree shake component/directive providers, for services that are created per-component/directive.

Describe the solution you’d like

Perhaps providedIn: Component? Not really sure.

Describe alternatives you’ve considered

No general solution that I know of.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
LayZeeDKcommented, Jul 16, 2019

That’s a somewhat arbitrary distinction to make for “UI” and “non-UI”. Sure, 14 days later even I am struggling to figure out what I meant.

What I meant was that pre-Angular 6 we would have providers in Angular modules. That meant that there could be a reference to a service even without it actually being used in the application.

Using Injectable or InjectionToken, we only have references to the dependencies if other dependencies or declarables (components, directives, and pipes) actually depend on them.

So I’m simply trying to state how they make a difference for Angular projects. But you are probably already aware of this.

0reactions
angular-automatic-lock-bot[bot]commented, May 15, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tree Shakeable Providers and Services in Angular - Cory Rylan
Angular recently introduced a new feature, Tree Shakeable Providers. Tree Shakeable Providers are a way to define services and other things ...
Read more >
Tree-shakable dependencies in Angular projects
We've looked at modern options for configuring injectors with tree-shakable providers. Compared to the providers in the pre-Angular 6 era, tree- ...
Read more >
What are Services and Tree Shakable providers in Angular ...
Services helps us to share common business logic, data and functions with different components of an Angular application. They are implemented through ...
Read more >
Why are "providers" in components or modules not tree ...
If you use the providers way, then the application considers the service as a dependency and will not tree shake it.
Read more >
The new Treeshakable Providers API in Angular
Treeshakable providers come with a new optional API that helps tools like webpack or rollup to get rid of unused services during the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found