-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reducers are not called when using --prod flag #147
Comments
I'm facing the same problem, actually some reducers are called at the beginning, then after not. export const reducers: ActionReducerMap<IStore> = {
ui: UiReducer.reducer,
users: UsersReducer.reducer,
workspaces: WorkspacesReducer.reducer,
buses: BusesReducer.reducer,
busesInProgress: BusesInProgressReducer.reducer,
containers: ContainersReducer.reducer,
components: ComponentsReducer.reducer,
serviceUnits: ServiceUnitsReducer.reducer,
serviceAssemblies: ServiceAssembliesReducer.reducer,
sharedLibraries: SharedLibrariesReducer.reducer,
};
// if environment is != from production
// use storeFreeze to avoid state mutation
const metaReducersDev = [storeFreeze, enableBatching];
const metaReducersProd = [enableBatching];
export const metaReducers = environment.production
? metaReducersProd
: metaReducersDev; And then use them as follows: @NgModule({
imports: [
StoreModule.forRoot(reducers, { metaReducers }),
EffectsModule.forRoot([
WorkspacesEffects,
BusesInProgressEffects,
UsersEffects,
UiEffects,
BusesEffects,
ContainersEffects,
ComponentsEffects,
ServiceAssembliesEffects,
ServiceUnitsEffects,
SharedLibrariesEffects,
]),
// it'd be nice to have the possibility to activate redux devtools
// even if we're in prod but only with the extension
// since ngrx v4, no idea how to do that
!environment.production
? StoreDevtoolsModule.instrument({ maxAge: 50 })
: [],
...
],
providers,
})
export class CoreModule {}
|
Note also than the effects are triggered. |
I found the issue in my case! :) The reason is that I used a named exported default function in export default function reducer() I removed the default export and changed it to export function reducer() and imported it like import { reducer } from './pet/reducer' |
@morhi that wasn't my problem, and even though you found a workaround, there is still something wrong. Would you be kind enough to reopen this issue? Thanks :) |
sure :) Unfortunately I don't have any idea for your issue right now.. |
@victornoel i imagine its an edit of the code after pasting, but why is the |
@victornoel You might wanna check #116 |
@morhi thanks :) Thanks all for the ideas, I will report on workaround if I find one and let's keep this open to track the problem until it is fixed for real :) |
@Kaffiend suggestion didn't help unfortunately :/ |
@victornoel Did you try the Object.assign hack mentioned in #116? That was the key to fix my AOT issue. |
Can someone reproduce this in a repo? It would help us diagnose the problem if there is one |
@brandonroberts this project with this branch reproduces the problem: https://gitlab.com/linagora/petals-cockpit/tree/front/update-deps |
I couldn't make a repro and now I won't have the time, sorry, I hope the repo I gave you will be enough :) |
@MikeRyanDev could you please reopen? I don't think this PR solve this issue as discussed on the PR… |
@victornoel can you open a new issue for this? I don't think the issue with the reducer factories applies to your situation |
@brandonroberts here it is #189, I reproduced the problem with latest nightly that contains #153. |
have you checked if build your app with |
hello :)
I try to migrate my ngrx store to v4 and I have an issue when using the
--prod
flag withng serve
orng build
.The store is splitted up in directories of modules and I bundled the store imports into a separate
NgModule
. TheStoreModule
is then imported in theAppModule
../store/index.ts
./store/pet/reducer.ts
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
The text was updated successfully, but these errors were encountered: