**Goal** 

I'm trying to deliver a typescript module augmentation of rxjs as an npm package to be used in Angular projects.

**Problem** 

Using the package in an Angular app works fine in local dev mode but once the app is built for production the package is not being imported in the final dist.

**Details** 

* Mostly the augmentation is providing a new method : **Observable.safeSubscribe()**  

*(complete source code here: [ngx-safe-subscribe.ts](https://github.com/Badisi/ngx-safe-subscribe/blob/master/ngx-safe-subscribe.ts))*

```
import { Observable, Subscription } from 'rxjs';

declare module 'rxjs/internal/Observable' {
    interface Observable<T> {
        safeSubscribe: typeof safeSubscribe;
    }
}

export function safeSubscribe<T>(...): Subscription {
    ...
}
Observable.prototype.safeSubscribe = safeSubscribe;

```
* The package is built with [ng-packagr](https://github.com/ng-packagr/ng-packagr)
* Once imported and used in an Angular project, everything works fine:  

*(complete demo here: [demo](https://angular-gygiz3.stackblitz.io))*

```
import { Component, OnDestroy } from '@angular/core';
import { of } from 'rxjs';
import '@badisi/ngx-safe-subscribe';

@Component({
    selector: 'my-app',
    templateUrl: './app.component.html'
})
export class AppComponent implements OnDestroy  {
    constructor() {
        of([]).safeSubscribe(this, () => { console.log('ok'); });
    }
    ngOnDestroy(): void {}
}

```
* Once built for production the package is not imported in the final dist: 

```
ng serve --prod

[error in console]: TypeError: Object(...)(...).safeSubscribe is not a function

```
* My last attempts were made with everything latest 

```
angular@7.0.0, typescript@3.1.3, ng-packagr@4.4.0

```
* On a side note, using the named import style in Visual Studio Code results in the following: 

```
import { safeSubscribe } from '@badisi/ngx-safe-subscribe';

[ts] 'safeSubscribe' is declared but its value is never read. 

```

It's hard to tell if the problem comes from typescript, angular-cli, webpack or even ng-packagr not being able to recognize the augmentation and properly import it in the final dist. 

So any help would be very very appreciated!  

Thanks.