Store: No AOT support

Created on 11 Jun 2019  路  12Comments  路  Source: ngxs/store

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => https://github.com/ngxs/store/blob/master/CONTRIBUTING.md
[ ] Other... Please describe:

Current behavior


Doesn't work when using AOT.
As soon as @ngxs/storage-plugin tries to intercept the state it throws:

ERROR TypeError: Cannot read property 'split' of null
    at getValue (ngxs-store.js:602)
    at TapSubscriber._tapNext (ngxs-storage-plugin.js:115)
    at TapSubscriber.push.../../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._next (tap.js:45)
    at TapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at TapSubscriber.push.../../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._next (tap.js:51)
    at TapSubscriber.push.../../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at ReplaySubject.push.../../node_modules/rxjs/_esm5/internal/ReplaySubject.js.ReplaySubject._subscribe (ReplaySubject.js:67)
    at ReplaySubject.push.../../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:43)
    at ReplaySubject.push.../../node_modules/rxjs/_esm5/internal/Subject.js.Subject._trySubscribe (Subject.js:89)
    at ReplaySubject.push.../../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:29)

Expected behavior


To work when using AOT.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?


AOT is an important feature of the Angular CLI.

Environment


Libs:
- @angular/core version: 8.0.0
- @ngxs/store version: 3.3.2

For Tooling issues:
- Node version: v12.1.0
- Platform:  Windows

Most helpful comment

@andrewjrhill
True. I'll wait 4 more days so it will be a week. Then I'm gonna close it if it stays w/o repro.

All 12 comments

TL;DR
NGXS just doesn't work overall with AOT enabled.

Very strange, my projects are all written NGXS with storage plugin and use AOT

Show me repo example

@marcus-sa
Make a reproduction please, we all use this plugin in production and haven't met this before.

@marcus-sa Are you by any chance using Storage Plugin + Universal? I had a related issue then but I couldn't debug it. Just using Storage Plugin + AOT works fine for me

@internalsystemerror
@Dav1dde had a chance to fix that issue caused by combo storage + universal :tada:
Will be released in 3.5.0

My project is compiled with AOT and everything is working fine. Using the storage plugin too.
A github repo would definitely be helpful here (stackblitz cannot do AOT).

Another issue without steps to reproduce... the NGXS team should start rejecting these issues. You cannot expect the contributors to resolve an issue they are unable to debug.

@andrewjrhill
True. I'll wait 4 more days so it will be a week. Then I'm gonna close it if it stays w/o repro.

Closing this due to inactivity.

I don't want to accumulate a large amount of issues, there are too many issues without reproduction and we're not able to fix it just because we cannot determine what's going wrong.

I will reopen this issue immediately when we get a reproduction.

@andrewjrhill thanks for the good idea!

This works without AOT, but fails with it:

@NgModule({
  declarations: [AppComponent],
  imports: [
    NgxsStoragePluginModule.forRoot({
      deserialize(data) {
        // Do deserialization
      },
    }),
...

This works with/without AOT:

export function deserialize(data: any) {
  // Do deserialization
}

@NgModule({
  declarations: [AppComponent],
  imports: [
    NgxsStoragePluginModule.forRoot({
      deserialize,
    }),
...

I would suggest to update the docs, to provide info on this behavior somehow.

@kemenesbalazs would you want to make a PR?

Was this page helpful?
0 / 5 - 0 ratings