Skip to content

reducers are not called when using --prod flag #147

Closed
@morhi

Description

hello :)

I try to migrate my ngrx store to v4 and I have an issue when using the --prod flag with ng serve or ng build.

The store is splitted up in directories of modules and I bundled the store imports into a separate NgModule. The StoreModule is then imported in the AppModule.

./store/index.ts

import { StoreModule as NgrxStoreModule, ActionReducerMap } from '@ngrx/store';
import pet from './pet/reducer';

export const reducers: ActionReducerMap<RootState, actions> = {
  pet: pet
};

@NgModule({
  imports: [
    NgrxStoreModule.forRoot(reducers, RootInitialState),
    environment.devTools ? StoreDevtoolsModule.instrument({maxAge: 50}) : [],
    EffectsModule.forRoot([
      PetEffects
    ])
  ]
})
export class StoreModule {}

./store/pet/reducer.ts

import { PetState } from './state';
import * as actions from './actions';

export default function reducer(state: PetState, action: actions.Actions): PetState {
  switch (action.type) {
    // ...
  }
}

However, the problem is that in production mode the reducers are not called. I can see the actions dispatched but the state is not changed. In development mode everything works fine. The console does not throw any errors or warnings. I hope that one of you has an idea how to fix it :)

I am using node v8.1.4 and @ngrx/store v4.0.0

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions