Skip to content

Implement tree-shakeable providers introduced in angular v6 #298

@crhistianramirez

Description

@crhistianramirez

https://blog.ninja-squad.com/2018/05/04/what-is-new-angular-6/

Basically by defining our services this way they will be tree shaken. Meaning if a service isn't used it won't be included in the final bundle. To do that we must define our services like this:

@Injectable({
  providedIn: 'root'
})
export class OcMeService{

}

And then remove the service definition in the relevant module. New services that are created will already be build this way so we'd just need to clean up the old usage.

Other pretty awesome benefits:

  • services wont need to be registered in modules they'll "just work"
  • non-mocked services won't need to be defined in tests they'll "just work"

Metadata

Metadata

Labels

architectureChange to how the app is built or architectedenhancementEnhances a current feature or component

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions