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

Next.js: RSC/App Dir #1400

Closed
ScriptedAlchemy opened this issue Sep 17, 2023 · 7 comments
Closed

Next.js: RSC/App Dir #1400

ScriptedAlchemy opened this issue Sep 17, 2023 · 7 comments

Comments

@ScriptedAlchemy
Copy link
Member

ScriptedAlchemy commented Sep 17, 2023

Knowns:

  • RSC is async, providing a free "async boundary" and independent entrypoints.
  • React is divided into four distinct singletons:
    • react-dom/server
    • react-dom/server/rsc
    • react
    • react/rsc
  • Crossing a server-client boundary involves:
    • Switching from "use client" to "full react"
    • RSC employs a module proxy to export metadata for isolated execution
    • The proxy returns a serialized render tree

Known Issues:

  • React must be externalized due to some of Next.js being outside the webpack scope, leading to version conflicts.
  • Four instances of React are present:
    • Normal Use Client
    • Server Components Subset
    • Browser/Server
  • Loader layers were unsupported in previous versions, but references in webpack source indicate potential changes. Webpack Layers
  • Forking React Flight plugin is complicated due to an existing internal fork in Next.js. ReactFlightWebpackPlugin

Perspective:

  • RSC has not yet proven business value, giving it low priority.
  • Next.js makes initial support exceptionally hard.
  • Easier wins, in time, will produce higher gains.

Ideas:

Reality:

  • Next.js isn't built for this architecture, primarily due to async issues.
  • The plugin is "fighting the framework," making it a tough battle.
  • Next 13.5 introduces package import optimization, which may interfere with module sharing.
  • Theres significant progress by osmosis, for example feat: NextJS - improve async startup #1433 which is largely a side effect of improvements designed for the larger ecosystem. So in time itll likely work itself down to a lower cost / time to support.

Want to help?

Any progress is welcomed!

Where to start

  • This branch https://github.com/module-federation/universe/tree/1400-nextjs-rscapp-dir can be forked and used as a stash point for any progress.
  • [] update example apps to reflect the problem, by using AppDir on one of them
  • [] exposed modules need to support webpack layers, like entrypoints and loaders do
  • [] share scope needs to share all the new packages, like react/navigation and so on, one may want to experiment with two shareScope keys, like default and rsc, so RSC parts are shared via the right library and not use client react
  • [] check and see what build name comes up, rsc likely is another webpack compile, if so that would be helpful to identify if any build info on the compiler lets us know what to do
@duannx
Copy link

duannx commented Sep 20, 2023

@ScriptedAlchemy Does that mean MF already supported App Router with these known issues? Or do we need to fix these issues first to make MF work with App Router?

@ScriptedAlchemy ScriptedAlchemy added state: Blocked area: Next Plugin and removed wontfix This will not be worked on labels Sep 20, 2023
@ScriptedAlchemy
Copy link
Member Author

@ScriptedAlchemy Does that mean MF already supported App Router with these known issues? Or do we need to fix these issues first to make MF work with App Router?

Need to fix. Soon as you add it. I believe it starts crashing. Likely due to react is "two" copies now. The full set and a subset depending on who imports it not how it's imported.

@ScriptedAlchemy
Copy link
Member Author

Okay it looks like #1433 - using the forked version of module federation, i can enable it to track initialChunks as well, then wrap entrypoint runtime callback in the chunk handlers federation normally uses, causing a eager entry to await its own startup while federation checks its chunkid againt its now "all knowing" chunk maps.

@alimsadeghi1
Copy link

Hello,
I would like to kindly bring attention to this issue and request that it be prioritized as high. This issue is causing a significant impact on our project workflow, and resolving it quickly would greatly benefit our team. Thank you for your understanding and assistance in this matter.

@ScriptedAlchemy
Copy link
Member Author

ScriptedAlchemy commented Nov 1, 2023

Hello,

I would like to kindly bring attention to this issue and request that it be prioritized as high. This issue is causing a significant impact on our project workflow, and resolving it quickly would greatly benefit our team. Thank you for your understanding and assistance in this matter.

Best way to move it forwards is looking over "how to help"

Given current bandwidth and demand. I'll likely only start looking at it in a few months. Community is welcome to help, which will speed up the timeline significantly

Copy link
Contributor

github-actions bot commented Jan 1, 2024

Stale issue message

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2024
@ScriptedAlchemy
Copy link
Member Author

#2002

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

No branches or pull requests

3 participants