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

server-side-rendering examples do not seem to work out-of-the-box #2799

Closed
DevLab2425 opened this issue Mar 2, 2023 · 4 comments
Closed

Comments

@DevLab2425
Copy link

DevLab2425 commented Mar 2, 2023

On a fresh clone of this repo, and a build and serve of the /server-side-rendering example, the app launches properly, however, the initial HTML does not include any content outside of the Host files. This does not seem to be expected for a true SSR experience which should contain a full HTML page worth of markup. In this example, this is not the case.

Additionally, the /server-side-render-only example, which does render the HTML on the first load, has an interesting configuration for the Host that seems to contradict the "over the wire" nature of MF. As Seen here in the Host webpack.config.js, it uses a relative path for the remote path. I would expect that all Remotes be absolute URLs to another server. Was the relative path intended or required for SSR in this use case?

One last item, I've noticed that in each of these examples they include self-contained servers for each of the Host/Remote combos with dedicated Webpack config files. Is a server Webpack build a requirement for SSR MF? Could the Remote client files theoretically be built and hosted via S3 (or similar) without requiring a separate Webpack build for a dedicated file server?


Between these two SSR examples, neither one is fully functioning as would be expected for SSR. Can someone help me determine what the ideal settings would be for a SSR MF implementation using React 18? Ideally, it would be compatible with an architecture consisting of a NextJS Host with n# Remotes running either a custom ExpressJS app or another NextJS application.

Thanks in advance and please let me know what else I can do to assist here.


Screenshots

Rendered UI with Remote components
Screen Shot 2023-03-02 at 5 45 21 PM

Page Source missing Remote HTML
Screen Shot 2023-03-02 at 5 45 47 PM

@ScriptedAlchemy
Copy link
Member

these SSR apps are older, my basic examples dont showcase a robust server & client example - but its absolutely possible and we have implemented it for others.

You can use both next and vanillia ssr apps without much issue as we have done in the past, but I dont have a good foundation SSR application to demo module federation over - mostly i either show it working on server in node, or in client, next just does both because its configuring the various parts.

So while possible, my ssr demos that are not next based likely are too simple and need to be revised

@brunos3d might have a proper ssr example

@brunos3d
Copy link
Contributor

brunos3d commented Apr 5, 2023

@ScriptedAlchemy @DevLab2425 We have a more up-to-date SSR sample with React here
https://github.com/module-federation/module-federation-examples/tree/master/react-18-ssr

@wibed
Copy link
Contributor

wibed commented Jul 6, 2023

the example provided seems to have some issue.
ootb i get the following error:

ScriptExternalLoadError: Loading script failed.
(missing: http://localhost:3001/client/remoteEntry.js)
while loading "./Content" from 9223

Note: Error in firefox.
on chrome in works fine

#307

@apadiyar-chwy
Copy link

@ScriptedAlchemy @brunos3d
tried the examples in folder, but i am seeing issue with SSR version
checked next js version as it was recommended earlier in this thread.

When i make change to remote app's component and restart remote app,
in initial server response on host app, remote component's html code still reflects the old code.
hydrate actually updates the html on browser

Is it possible to make initial server response on host app reflect remote component's change ?

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

No branches or pull requests

5 participants