0

We have an Angular 5 sandbox application in which are handled components I'd like to reuse in other applications, with a demo component that simulates integration of those components in a real app.

We use ng-packagr to build components in our lib folder as adviced so that we can reuse them in other app as npm package.

Everything was working fine until one commit made ng-packgr build generate error at runtime : all services called from components constructor are not provided.

ERROR TypeError: Cannot read property 'someObs$' of undefined

Where someObs$ is an observable of a service that is called in a constructor of a Component :

constructor(protected someService: SomeService) {
    this.someService.someObs$.subscribe(() => {
      // ...
    });
  }

Nothing critical in this commit and more importantly nothing impacting on service providing architecture, modules, etc..

Of course all my providers are correct since the error occurs only with ng-packgr build and not with ng serve local development.

EDIT : Updated problem linked to ng-packagr build process

Aphax
  • 169
  • 3
  • 14

0 Answers0