-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Integrate ssr #157
Integrate ssr #157
Conversation
b761f23
to
24a7aa5
Compare
d6e78e6
to
62b7a95
Compare
The landing page, docs and Most examples are working here now. The remaining issues with some examples are related to the ngOnRender() in the map.component still running server-side, as I mention in here, which it of course shouldn't, but I'm still not clear on how to make it client-only e.g. with afterNextRender/afterRender. Effectively, I just take the content of ngOnInit and put it inside an afterNextRender in the constructor. I have had to disable the content of the ngOnDestroy on multiple occations, because it's being ran servers-side not having access to a global window object etc. - this is somewhat ad-odds when using the library in a SPA where it's important to do the cleanup, but I don't know how to conditionally disable it yet or mark the ngOnDestoy, or entire component for that matter, as client-only. |
if (this.mapService.mapInstance.hasControl(this.control)) { | ||
this.mapService.removeControl(this.control); | ||
} | ||
// if (this.mapService.mapInstance.hasControl(this.control)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could use "?" here so that if this is not initialized, then it won't do anything, can't you?
I'm not very worried about SSR memory leaks for this lib, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more concerned about leaks on the client actually, where the objects are created, because the SSR apps today often do soft navigation where possible, so they won't necessarily clean up the client until a proper page refresh is performed. I can see this when debugging the examples - I had to go into each one and only when i hit refresh they'd trigger some error. Initializing on the client, and cleaning up on the server, or vice-versa, looks to me like asking for trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yea I get your point here.
I'll see if I can look into it in the next few days...
Documentation is so lacking that it makes this whole process very painful...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about injecting the platform to check if its the browser and then do the clean up?
private readonly _isBrowser: boolean = inject(Platform).isBrowser;
ngOnDestroy() {
if(this._isBrowser) {
...
}
}
It's used by the angular team in the components repo too e.g.
Co-authored-by: Harel M <harel.mazor@gmail.com>
@marcjulian this PR is against a branch to solve github SPA problem and allow SEO for the demo pages. |
@HarelM I can work on this, when I find more time. Yes I saw the Githup SPA issue, will be great when the library supports SSR anyways. |
I have no clue how to continue. |
@marcjulian feel free to tackle this. These error messages are too cryptic for me to understand and it seems like the prerender is in experimental state or something... IDK... |
@HarelM I got prerendering working, however, only with I still had some issues with the I also removed the When I set I will try to find some time to add all routes to the |
projects/showcase/src/app/demo/examples/live-update-feature.component.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
ngOnDestroy() { | ||
this.portalOutlet.detach(); | ||
if (this._isBrowser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we simply check if portalOutlet os not null?
Besides the above nit picking this is a good step forward. |
* update to browser-esbuild * upgrade to application * bump deps * ng update changed tsconfig * Fix package version * update deploy path * fix lockfile * Integrate ssr (#157) * Enable SSR with migration script * Add zone.js to polyfills * Make Map component SSR compatible * Make "Scroll demo into view" client only * afterNextRender in layout-toolbar-menu * afterNextRender in control.component.ts - fixes terrain example * Lint - Update projects/showcase/src/app/app.config.ts Co-authored-by: Harel M <harel.mazor@gmail.com> * use withFetch to fix Error retrieving icon * add custom loader for svg, fix loading icons on server * fix loading map for ssr app by removing base-href * detach portal in browser only * remove polyfills * replace window functions * create popup in browser only with afterNextRender * cleanup unused lifecycle hooks, remove control only in browser * prerender with routes file * Update projects/showcase/src/app/demo/examples/live-update-feature.component.ts --------- Co-authored-by: Harel M <harel.mazor@gmail.com> Co-authored-by: Marc Stammerjohann <8985933+marcjulian@users.noreply.github.com> * Small changes to docs * Fix test due to change in life cycle * Added more routes * ignore problematic routes * Add ignore to another test * Allow prerender for all routes (46) * Fix live update of image source * Simplify code a bit * fix multiple selectors for clear search button --------- Co-authored-by: Harel M <harel.mazor@gmail.com> Co-authored-by: Marc Stammerjohann <8985933+marcjulian@users.noreply.github.com>
This work is to enable SSR, allowing loading pages outside of the "/" url