Since we upgraded to the latest version of this repo our state rehydration fails.
Found this in app.module.server
// HttpTransferCacheModule still needs fixes for 5.0
// Leave this commented out for now, as it breaks Server-renders
// Looking into fixes for this! - @MarkPieszak
//ServerTransferStateModule
Any ideas when this will be fixed? Can you @MarkPieszak point me in the right direction and then I can investigate as well.
I'm trying to look into this as well, any help would be appreciated.
What i've discovered so far:
ServerTransferStateModule - no html is outputted, i was debugging to understand why its returning "" , what i've noticed is that within angular https://github.com/angular/angular/blob/master/packages/platform-server/src/utils.ts#L63 its actually outputted.TransferState) alone, however the moduleRef is not exposed if it was i could fix it. As i managed to hack it however without using the new module renderModuleFactory and @nguniversal/aspnetcore-engine (which im not happy to do)update: what i noticed is when registering ServerTransferStateModule the universal beforeAppSerialized is not being triggered.. cant understand why because both uses multi: true
update#2
So pretty much I have a working solution and got it working on our project, but it requires some changes, ideally in both angular and universal
aspnetcore-engine tomorrow I will try to submit a PR to it, and move the breaking change temp in it gets accepted TransferState will work for aspnet 馃巻 @stephenlautier You rock!
Let me talk to the team and see if we can push in those changes asap so we can publish a new version of the engine etc out!
@MarkPieszak Any updates?
A new update has been released (in angular/universal repo) about a week or so ago, can you give it a shot and let us know if it's working? @Flood
It seems to work! State rehydration works on my project but SSR does not. It breaks on
ERROR ReferenceError: Event is not defined (see https://github.com/angular/universal/issues/844)
However, SSR works on this repo. I guess it will work on my project when the Event issue is solved.
Excellent 馃憤
That might be coming from a third party library you have (?)
Just add global['Event'] = null; to your boot.server.ts file, and that should help the issue.
A lot of times you need to mock/stub things in Node to handle crazy global (typically browser-only items). Unfortunately a lot of people forget you should always check for the existence of global variables :(
Closing as TransferState works now 馃拑
Most helpful comment
@stephenlautier You rock!
Let me talk to the team and see if we can push in those changes asap so we can publish a new version of the engine etc out!