Skip to content
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

Initial state still empty in AOT as of v4.1.0 #515

Closed
GiuseppePiscopo opened this issue Oct 21, 2017 · 6 comments
Closed

Initial state still empty in AOT as of v4.1.0 #515

GiuseppePiscopo opened this issue Oct 21, 2017 · 6 comments
Assignees

Comments

@GiuseppePiscopo
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

I've read through related issues, #116 , #189 , #247 and especially, #258 . I've successfully applied the InjectionToken/getReducers workaround as suggested in latest comment by @brandonroberts .

It is not clear to me whether injecting reducers map by token is the way to go forward or what. If that's the case, would you consider a PR making this explicit in docs? Otherwise, this issue is to notify that AOT problem still persists as of 4.1.0.

What is the current behavior?

When a ng-cli based project is built for production with AOT enabled, at runtime the application state seems to be stuck as an empty object {}. Initial state passed in single reducers seems to be ignored. Also trying to pass initial state when calling StoreModule.forRoot(...) seems to be ignored. The only change I could experience in application state has been when some router action was fired: then just the router slice of app state was created.
When project is built for development, app state is correctly populated. I've not tried building for production but with AOT disabled.

Expected behavior:

Even when compiling project for production, with AOT enabled, application state should be correctly populated as in development build.

Minimal reproduction of the problem with instructions:

Sorry for not providing a demo. Is there a seed project available in stackblitz? I took it you can try AOT builds there, as opposed to Plunker.
Steps:

  • Create a project with ng-cli
  • Add ngrx store + effects + router-store 4.1.0. Also useful is store-devtools. Set those up with a minimal application state
  • Build project for development and serve that: observe no runtime errors and, from Redux devtools, state is filled
  • Build project for production and serve that: see runtime errors and state is empty

Version of affected browser(s),operating system(s), npm, node and ngrx:

Tried with Google Chrome 61.0.3163.100 64 bits
Windows 10 64 bits
node v6.9.5
npm 3.10.10
ngrx 4.1.0
angular 4.3.4

Other information:

@brandonroberts
Copy link
Member

@GiuseppePiscopo I haven't been able to reproduce this in the example app using the -prod flag. Can you provide a reproduction?

@GiuseppePiscopo
Copy link
Author

Ok, I'll try. BTW, where's the example app? And, is there a plunker or stackblitz seed, ngrx-included, to start with? Thanks

@brandonroberts
Copy link
Member

The example app is in this repo https://github.com/ngrx/platform/tree/master/example-app

@GiuseppePiscopo
Copy link
Author

Thanks, currently working at it. Actually I first "moved" example app into a new empty ng-cli project. At the moment I'm not able to reproduce the issue there.

If it might help: initially I met some funny errors related to angular material and MaterialModule not being defined. Apparently there have been some breaking changes across beta versions and one way to fix them is by pinning them to some specific versions:

"@angular/material": "2.0.0-beta.7",
"@angular/cdk": "2.0.0-beta.8",

@GiuseppePiscopo
Copy link
Author

As said, I was not able to reproduce the issue then, and I'm not having time to try again, so I'd say we can close this.

OT you might want to give a shot at that dependency issue mentioned in comment above. HTH

Regards

@brandonroberts
Copy link
Member

We landed a PR to lock the material versions. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants