-
Notifications
You must be signed in to change notification settings - Fork 13.5k
@ionic/angular 4.beta.0 with Angular Universal (Server Side Rendering) ERRORS #15041
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
Comments
Thanks a lot for the detailed issue report! We'll get this sorted out |
@adamdbradley @mhartington |
@adamdbradley posted this some days ago in the Ionic slack:
|
As a workaround in an 4.0.0-beta.11 app, I used @ng-toolkit/universal as is with some adjustments in the generated // see https://github.com/angular/universal/issues/830#issuecomment-345228799
import { createWindow } from 'domino';
import { readFileSync } from 'fs';
import { join } from 'path';
const template = readFileSync(
join('.', 'www', 'browser', 'index.html')
).toString();
const win = createWindow(template);
global['window'] = win;
global['document'] = win.document;
global['navigator'] = win.navigator; Now the Ionic bootstrap works, and I can see the SSRed code. I still have many server-side errors due to other browser types / methods notably because of external directives that have the same issues. Edit: also https://github.com/Angular-RU/angular-universal-starter/blob/master/server.ts |
Hey Guys, Any update on this issue. What is the target date for full SSR support. We are waiting for SSR fix to go live with our couple of websites. |
@adamdbradley I saw you moved the issue from I know the framework is maturing fast and now there are many open fronts (@ionic/react, @ionic/vue not just @ionic/angular anymore) and that leaves some features behind. |
Hey there! Just chiming in to provide an update. As we're getting closer to RC/final, we're finalizing any major APIs that are required. SSR is still something that we intend to work on supporting, but it there are a few bigger issues that require all of our attention. @agustinhaller I'd gladly accept a PR that improves our SSR story if you make it. Happy to work with you too. Feel free to reach out and I'll lend a hand where I can. mike at ionic dot io. |
@mhartington would love to contribute. I'm pretty busy right now, but as soon as I become available will definitely get on this. |
Have tried adding both @nguniversal and @ng-toolkit/universal and both cases come up with this error |
Is there any progress on this? I've tried several different hacks to get this to work - all of which result in the need for more hacks, and more, and more. This is a gaping hole in the Ionic Framework and is undoubtedly harming uptake. I've built a large app with Ionic and now realise I can't do SSR (with Angular Universal). Would really appreciate any news, or other solutions from those in a similar situation. |
I think Adam is working on it, close to see something pushed: https://twitter.com/adamdbradley/status/1099418644637982722 |
When I implement SSR I an error below
Is there any progress on this? |
Is there any update? |
Stencil |
Many thanks @adamdbradley for the update. I wonder to know if I compile an IONIC+Angular project with IONIC-cli v5. I would have the same performance than using and compiling under Stencil. |
Next release of @Ionicframework will use @stenciljs one: b40f7d3 … Smaller/faster components, and using Constructible Stylesheets 💎 |
Thanks for the update @UTSOURCE, I am really looking forward to this, to improve the SEO of my PWA. :) |
I am running on the recent
|
@salmoro You might need to wait until Ionic 4.7.0 |
Angular 8 support was announced yesterday. Any ETA for SSR support in ionic? :) |
The latest version seems to support ssr |
Could you please describe what steps you took to integrate SSR into your Ionic app? |
|
I don't think so. After installing the latest version and the command
it's showing up
|
I also found this problem when I tested it, or wait for the official reply. |
@UTSOURCE server-side applications can't reference browser-only global objects like window & document. You have to managed that in your code. |
@berchik |
@UTSOURCE then it must be coming from one of the packages of ionic/webpack, we need to wait for someone from the Ionic team to reply. |
I am not sure if that's related, but for some of my project using pure angular. If there is something use window object, I need to make a fake object by using domino library in order to make ssr work. Let's wait for an official answer. |
Try for a few hours, even window is mock, it still give error of |
@mhartington Is ssr available? |
@mhartington same question :/ |
SSR still doesnt work with ionic, I get ReferenceError: window is not defined |
@jaapjanfrans Yes, it can't be used, but I see that ionic has submitted code about ssr. |
Really looking forward to this. Are there any news? |
Just to update everyone here, we've been slowly making progress here. It's involved a lot of moving parts (on angular and Ionic) to make this possible, so I appreciate everyone being patient with this. https://twitter.com/mhartington/status/1160941457131356164 We will have more updates (probably a blog too?) to go over SSR soon. |
Hi! Any news on this? Thanks for your work! |
A little can't wait |
Well... I think we are making progress. |
cannot wait any more! Any news about this? |
@GeoffMahugu .Have you solved this error ? |
@Ashok-raj-1994 Naah had to change the application architecture to Angular only but pretty sure they'll have a solution soon |
@GeoffMahugu I guess the official temporarily stopped the development of this piece. My basis is that the official ssr-related code has not been updated for 2 months, and the ssr branch project has been deleted. |
Can we get any official response about the state of SSR? |
I gave folks an update here. There's a lot involved with SSR and making sure things work as expected. We will provide more information when we have something to talk about. |
So, this took longer than expected! Thank you all for waiting, here are our updates. https://ionicframework.com/blog/ssr-with-angular-universal-and-ionic/ Please test this out and open a new issue if there are any problems. |
Bug Report
Ionic Info
Describe the Bug
Ionic 4.beta.0 with Angular Universal (Server Side Rendering) ERRORS
Steps to Reproduce
Steps to reproduce the behavior:
Related Code
Right now my tests are tightly coupled with my project's code. I can update this issue with a clean repo if needed.
Expected Behavior
@ionic/angular plays nicely with Angular Universal
Additional Context
Hi I’m opening this issue to expand these recent Twitter threads (thread 1, thread 2) and discuss a bit further the improvements that the @ionic/angular module should have in order to properly support server side rendering ‘the angular way’ with Angular Universal (@nguniversal).
Also expanding discussion about this same topic from issue: #14574
These are the issues I found:
1. The @ionic/angular project structure needs a specific module to wrap all the native related stuff.
The same way Angular recommends having a module specifically for your application when running on the server, I think we need a specific module for all the
ionic-native
stuff.Maybe an
app.native.module.ts
file with theAppNativeModule
where we should include all the ionic-native stuff like registeringSplashScreen
andStatusBar
as providers.2. @ionic/angular not following Angular Universal “gotchas”
When building Universal components in Angular there are a few things to keep in mind.
window
,document
,navigator
, and other browser types - do not exist on the server - so using them, or any library that uses them will not work.This is the case with the current 4.beta.0 version of
@ionic/angular
. There are plenty of references towindow
anddocument
inside @ionic/angular code.To point out a few:
In this same file, this line also fails. I don't know if it's because of the
await
or that you are manipulating the nativeElement directly (instead of using AngularRenderer2
).From my perspective I don't see any architectural nor design impediment in @ionic/angular code that could impact in these issues. Following Angular Universal gotchas would do the trick.
Please @mlynch, @mhartington, @manucorporat, @adamdbradley let me know what you think about it and if there's something I'm underestimating about these issues.
The text was updated successfully, but these errors were encountered: