title: Issue with redux undo package which only appears in production - Angular
body: <p>I'm trying to implement the redux-undo functionality in my app <a href="https://github.com/omnidan/redux-undo" rel="nofollow noreferrer">using the redux-undo package</a>. When I'm running it locally with ng serve, it works fine and without any error. But when I'm switching to production, the state seems to be undefined. This is my basic store setup:</p>
  
  <pre><code>export interface State {
     elementState: {
     past: ElementState[];
     present: ElementState;
     future: ElementState[];
     _latestUnfiltered: ElementState;
     group: any;
     index: number;
     limit: number;
    }
  }
  export const reducers: ActionReducerMap&lt;State&gt; = {
     elementState: undoable(
     elementReducer,
     {
       limit: 10,
       undoType: ActionTypes.UNDO,
       redoType: ActionTypes.REDO,
       filter: includeAction([DO_STUFF])
      }
    ),
   };
  </code></pre>
  
  <p>This is the error:</p>
  
  <blockquote>
    <p>ERROR TypeError: "t.elementState is undefined"</p>
  </blockquote>
  
  <p>I understand that this question is pretty general, but honestly I have no idea what the reason for the error could be since it works fine locally. Can anyone give me some input and point me in the right direction?</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p><a href="https://stackoverflow.com/a/46962135/8604157">Solution found here</a></p>
  
  <p>defining injectionToken on reducers/index:</p>
  
  <pre><code>export const reducerToken = new InjectionToken&lt;ActionReducerMap&lt;AppState&gt;&gt;('Registered Reducers');         
  Object.assign(reducerToken, reducers);
  </code></pre>
  
  <p>define getReducers factory(app.module):</p>
  
  <pre><code>export function getReducers() {
    return reducers;
  }
  </code></pre>
  
  <p>when registering modules on app.module: register reducerToken and provide it in provders section:</p>
  
  <pre><code>imports:[   
     ...
     ...
     StoreModule.forRoot(reducerToken)
  ],
   providers: [
  {
     provide: reducerToken,
     useFactory: getReducers
  }
  </code></pre>