repack icon indicating copy to clipboard operation
repack copied to clipboard

When do you plan to support the Module Federation ?

Open scdmn opened this issue 4 years ago • 4 comments

Ask your Question

I want to know your plan for module Federation, which is very important for react native to dynamically load third-party applications

scdmn avatar Jul 23 '21 08:07 scdmn

The ETA for Module Federation is still unknown. We're focusing on Code Splitting in form of async chunks first, as the infrastructure for supporting async chunks and Module Federation is almost the same, so we have to establish a solid foundation before going into deep water with Module Federation.

That being said, it is possible to dynamically load third-party applications even without code splitting. It requires some deeper knowledge about Webpack but it's possible with some caveats:

  1. Dynamically loaded application cannot add any native code (which is true for both async chunks and Module Federation).
  2. A common/shared dependencies like React, React Native + any other public API has to be extracted into separate NPM package and built with Webpack + Re.Pack as a library.
  3. Each 3rd party application uses the aforementioned library, any other dependency is built into the 3rd party application (so it's possible to have a duplicated code - tradeoff) and is built using Webpack + Re.Pack as a library. Each 3rd party application can use a limited set of native APIs (only the ones available in host application).
  4. The host application, load the 3rd party application using ChunkManager.loadChunk. The 3rd party application, is not actually a chunk, but it doesn't matter. ChunkManager.loadChunk will work for any kind of JS code.

That's the gist of it.

It would be good to have this as an example. If anyone want's to give it a try, feel free to reach out to me.

zamotany avatar Jul 26 '21 12:07 zamotany

The Module Federation support is still in early stages, but the core functionality is working in development mode - production mode might work might not.

https://github.com/zamotany/module-federation-repack

zamotany avatar Dec 20 '21 17:12 zamotany

Hey! We know the ETA now and it's June 2022. @zamotany will work to make this feature production ready in May and June (if necessary) as a part of our R&D efforts at Callstack. Stay tuned :)

thymikee avatar Mar 21 '22 11:03 thymikee

I owe you some update: the bulk of work is done and available under the next tag on npm (v3.0.0-alpha.6 at the time). There's an example you can follow: https://github.com/callstack/repack-examples/tree/main/module-federation

But we still miss the migration guides, polishing, and proofing this in real projects. That's why the stable v3 will have to wait a bit long. How long? That's what @jbinda will be able to tell next month :)

thymikee avatar Aug 01 '22 12:08 thymikee

Official Module Federation support was released in 3.0.0 version of repack.

RafikiTiki avatar Dec 28 '22 15:12 RafikiTiki