Module federation with Next JS with out @module-federation/nextjs-mf

57 views Asked by At

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.

  1. Convert the app router to a page router
  2. 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.

1

There are 1 answers

0
Mohammad Shahzaib On