title: Using NgRx (with ngrx-actions library) within an Angular 6 library
body: <p>I am trying to split up an Angular application with multiple modules into multiple (separate) Angular libraries (using <a href="https://github.com/angular/angular-cli/wiki/stories-create-library" rel="noreferrer">this guide</a>), so I can use these libraries within multiple Angular applications.<br>
  Currently the project has several modules, for example:</p>
  
  <ul>
  <li>One for authentication/authorization;</li>
  <li>One containing all kind of table components</li>
  <li>One containing all kind of filter components</li>
  <li>One containing all kind of chart components</li>
  <li>... (I guess you get the point) ...</li>
  </ul>
  
  <p>I started working on 'converting' the authentication/authorization module into a library, because I expected it would be the hardest and most complicated module.<br>
  Right now I am facing some problems which I will explain below. </p>
  
  <p>The module (as it currently exists) makes use of NgRx in combination with ngrx-actions to reduce boilerplate.  Like mentioned (in <a href="https://github.com/angular/angular-cli/wiki/stories-create-library" rel="noreferrer">the guide</a>), a library and an app for testing the library are created. 
  I copied all the contents of the existing module into the library folder.  </p>
  
  <p>Had to make some adjustments, because the existing module reads some constants from environment.ts and a global.ts which will (probably) not exist when it's used as a library.  </p>
  
  <p>Right now my folder structure looks like the following, to give some more context (removed the node_modules):  </p>
  
  <pre><code>.
  ├── README.md
  ├── angular.json
  ├── e2e
  │   ├── protractor.conf.js
  │   ├── src
  │   │   ├── app.e2e-spec.ts
  │   │   └── app.po.ts
  │   └── tsconfig.e2e.json
  ├── package-lock.json
  ├── package.json
  ├── projects
  │   ├── auth-lib
  │   │   ├── karma.conf.js
  │   │   ├── ng-package.json
  │   │   ├── ng-package.prod.json
  │   │   ├── package-lock.json
  │   │   ├── package.json
  │   │   ├── src
  │   │   │   ├── lib
  │   │   │   │   ├── auth-check
  │   │   │   │   │   ├── auth-check.component.html
  │   │   │   │   │   └── auth-check.component.ts
  │   │   │   │   ├── auth-guard.service.ts
  │   │   │   │   ├── auth-routing.module.ts
  │   │   │   │   ├── auth.module.ts
  │   │   │   │   ├── auth.service.ts
  │   │   │   │   ├── callback
  │   │   │   │   │   ├── callback.component.ts
  │   │   │   │   │   └── callback.html
  │   │   │   │   ├── interceptors
  │   │   │   │   │   └── auth.interceptor.ts
  │   │   │   │   ├── permission-guard.service.ts
  │   │   │   │   ├── signin
  │   │   │   │   │   └── signin.component.ts
  │   │   │   │   └── store
  │   │   │   │       ├── auth-state.interface.ts
  │   │   │   │       ├── auth.actions.ts
  │   │   │   │       ├── auth.effects.ts
  │   │   │   │       ├── auth.reducers.ts
  │   │   │   │       └── auth.store.ts
  │   │   │   ├── public_api.ts
  │   │   │   └── test.ts
  │   │   ├── tsconfig.lib.json
  │   │   ├── tsconfig.spec.json
  │   │   └── tslint.json
  ├── src
  │   ├── app
  │   │   ├── app.component.css
  │   │   ├── app.component.html
  │   │   ├── app.component.spec.ts
  │   │   ├── app.component.ts
  │   │   └── app.module.ts
  │   ├── assets
  │   ├── browserslist
  │   ├── environments
  │   │   ├── environment.prod.ts
  │   │   └── environment.ts
  │   ├── favicon.ico
  │   ├── index.html
  │   ├── karma.conf.js
  │   ├── main.ts
  │   ├── polyfills.ts
  │   ├── styles.css
  │   ├── test.ts
  │   ├── tsconfig.app.json
  │   ├── tsconfig.spec.json
  │   └── tslint.json
  ├── tsconfig.json
  └── tslint.json
  </code></pre>
  
  <p>public_api.ts is containing the following code:  </p>
  
  <pre><code>/*
   * Public API Surface of auth-lib
   */
  
  export * from './lib/auth.module';
  export * from './lib/auth-guard.service';
  export * from './lib/permission-guard.service';
  export * from './lib/auth.service';
  </code></pre>
  
  <p>auth.module.ts contains the following code:</p>
  
  <pre><code>import {NgModule} from '@angular/core';
  import {SigninComponent} from './signin/signin.component';
  import {AuthRoutingModule} from './auth-routing.module';
  import {CallbackComponent} from './callback/callback.component';
  import {AuthService, InternalAuthService} from './auth.service';
  import {HTTP_INTERCEPTORS} from '@angular/common/http';
  import {AuthInterceptor} from './interceptors/auth.interceptor';
  import {AuthEffects} from './store/auth.effects';
  import {EffectsModule} from '@ngrx/effects';
  import {AuthStore} from './store/auth.store';
  import {AuthCheckComponent} from './auth-check/auth-check.component';
  import {NgrxActionsModule} from 'ngrx-actions/dist';
  import {StoreRouterConnectingModule} from '@ngrx/router-store';
  
  @NgModule({
    declarations: [
      SigninComponent,
      CallbackComponent,
      AuthCheckComponent
    ],
    imports: [
      AuthRoutingModule,
      NgrxActionsModule.forRoot({auth: AuthStore}),
      EffectsModule.forFeature([AuthEffects]),
    ],
    providers: [
      AuthService,
      InternalAuthService,
      {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true},
      StoreRouterConnectingModule,
    ],
    exports: [],
  })
  export class AuthModule {
  
  }
  </code></pre>
  
  <p><strong>NOTE:</strong> this is working when the module exists within a project (not as library).<br>
  FYI: The different components are dispatching some actions, like redirecting to the (Auth0) log in page.</p>
  
  <p>Then.. when I want to import the AuthModule in the app.module.ts (the 'test application') I get the following error, which I can't solve.  </p>
  
  <pre><code>Error: StaticInjectorError(AppModule)[NgrxActionsModule -&gt; ReducerManager]: 
    StaticInjectorError(Platform: core)[NgrxActionsModule -&gt; ReducerManager]: 
      NullInjectorError: No provider for ReducerManager!
      at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1062)
      at resolveToken (core.js:1300)
      at tryResolveToken (core.js:1244)
      at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141)
      at resolveToken (core.js:1300)
      at tryResolveToken (core.js:1244)
      at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141)
      at resolveNgModuleDep (core.js:8376)
      at _createClass (core.js:8429)
      at _createProviderInstance (core.js:8393)
  </code></pre>
  
  <p>I saw <a href="https://github.com/ngrx/platform/issues/295" rel="noreferrer">this GitHub issue</a> and <a href="https://stackoverflow.com/questions/49127332/nullinjectorerror-no-provider-for-reducermanager">this Stack Overflow question</a>, both suggesting the same answer, but they are not working in my case.  </p>
  
  <p>Is there someone who knows how to fix this issue? Thanks!</p>