module-federation / core

Module Federation is a concept that allows developers to share code and resources across multiple JavaScript applications
https://module-federation.io/
MIT License
1.53k stars 235 forks source link

Migration offramp examples for nextjs #3190

Open MaykonMorais opened 1 week ago

MaykonMorais commented 1 week ago

Clear and concise description of the problem

With the change of next-mf status to maintenance, we noticed that it might be necessary to create examples for teams already considering migrating to other frameworks. I imagine that teams will make this transition gradually, so it would be helpful to consider a way for Next.js to interoperate with other frameworks, facilitating this change.

The examples could be organized by some recommended frameworks. Here are a few ideas:

I believe these examples will be very helpful for those already thinking about migrating and will be of great value to the community.

Suggested solution

Alternative

No response

Additional context

No response

Validations

ScriptedAlchemy commented 4 days ago

I think we will have to reverse the strategy.

Next.js (remote) with Rsbuild/Rspack (host) Next.js (remote) with ModernJS (host) Next.js (remote) with Remix (host)

Youd take your current host, make it a remote, and use a new host who actually works well to pull the legacy next app back into it.

Next hosts are almost impossible to accept non next remotes.

We would have to create share replacements/shims for link,router, etc - nextjs is a locked system and will only work with its own stuff.

Any shim we create to try and reverse the order, Vercel will most likely try and break. We would need to disable Vercels ability to use make changes in effort to eat up our bandwidth with games of cat and mouse, the best way to lock them out of manipulating next.js deliberately to break federation offramps is to remove them as host and put a non-adversarial host in place.

Next.js is largely weaponized against federation, we have to assume its owner is hostile and act accordingly.

MaykonMorais commented 3 days ago

I agree, this approach makes a lot of sense! Reversing the role of Next.js to act as a remote while using a host with better federation compatibility is a smart strategy, especially given the constraints of the Next ecosystem.

ScriptedAlchemy commented 2 days ago

Totally, ill work on something soon

zackarychapple commented 2 days ago

There are also some Tanstack examples in the works, with Tanstack Start coming along its a very interesting alternative as well.

ScriptedAlchemy commented 1 day ago

@zackarychapple do they work with SSR yet? I know vite base does not currently support ssr AFIK, are they rspack / webpack based?