I am transitioning from Java to JS and am currently working on a Next JS project. I got a requirement to share the client component from the Next JS project with another project that is built on React. I came across module federation and was able to build a sample demo with page router. Now I'm trying to implement the same in an actual project and found that the actual project uses an app directory or router. With the below reference link, I found that the that the @module-federation/nextjs-mf plugin is not supported for the app directory. Since it was not supported, I left with 2 options.
- Convert the app router to a page router
- Implement module federation without @module-federation/nextjs-mf plugin and use Webpack conventional module federation (I am not sure on the feasibility), similar to the React project.
Please provide your suggestion and share the reference to implement the same.
Reference https://github.com/module-federation/universe/issues/619 https://github.com/module-federation/universe/issues/799
Exception
Error: App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this at NextFederationPlugin.validateOptions
Please provide your suggestion and share the reference to implement the same.
There will be no support for App router in the future either
https://github.com/module-federation/universe/issues/1183#issuecomment-2003744775 https://github.com/module-federation/universe/pull/2002#issuecomment-2003747435