nextjs-sidecar example is confusing
See original GitHub issueGreat job on creating Module Federation. No doubt this is an important piece of how things will be done from now on. And quite awesome to see an example for implementation on NextJS. But I have to say the example itself is quite confusing, or at least not explained entirely. Why have a component (src/components/Dog.js
) - which lives under NextJS already - treated as a remote component within NextJS. Why this loop into itself? Is this part of how Module Federation works or just to showcase how to consume components from NextJS? Please clarify this bit.
One more thing, even in this simple example the performance is surprisingly bad, is SSR not yet working with Module Federation?
Thanks again!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Still a bit confused how sidecar and the various patterns work ...
so i suspect this sidecar example uses node.js pkg for the backend. I'm not familiar with node, so i suppose scripts and src...
Read more >Sidecar for a Code Splitting. Long story short - ITNEXT
The oldest way to code split. While it may still not be quite clear when and what a sidecar is, I'll give a...
Read more >Module Federation for React host and NextJS remote app ...
From the webpack config of the host, I can see that the next JS app is running on port 3002. You are getting...
Read more >AMA + Messing Around with Next.js & Module Federation
Hanging out for a little, while I attempt to get Module Federation working on Next. js.
Read more >The Sidecar Pattern for Application Developers - Medium
What ensued was a debate that introduced much confusion about the ages old sidecar / ambassador architectural patterns.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Check this repo for a NextJS folder. It’s all in there. SSR works but I did have to bolt on some extra boilerplate because next is missing a async boundary internally.
Working to resolve that with the team.
The sidecar build is this though.
Making next and non-next work together is pretty much the same process. take a next app as is, with its import mechanism, and start up a different app and import its component / repoint the remote.
if its client-side,
window.remoteName.get('./header')
will work, assuming the remote is on the page.SSR works with module federation, its next.js which does not work well with webpacks feature. SSR works on any other ssr example with far less complexity.
I made an example with bi-directional hosts. In reality, ill have apps that are just remotes, like component libraries. Those I import by injecting the script to the page myself, then manually initializing the remote inside a webpack 4 host, if its a webpack 5 host ill just import it as usual.
Webpack 4 cant share automatically, so we recreate some critical dependencies we want to share between WP4 and WP5 - manually.
Something like:
Perf is probably bad because I’ve put nothin in place for SSR script chunks or preloading, so it boots and loads. Havent really looked at the perf, what aspects were bad?