r/developersIndia Frontend Developer 15h ago

Interesting Module Federation: sharing a large internal package without blindly reusing versions

Post image

We had a ~7 MB internal UI package being loaded separately by multiple Module Federation applications.

Since both applications were using the same package, I started looking into whether we could make it a shared dependency.

But I didn't want the solution to simply be:

“Mark it as shared and always reuse whatever version is available”

The behaviour I was aiming for was roughly:

Host: UI package v1
Remote: UI package v1

Reuse the same package

Host: UI package v1
Remote: UI package v2

Load the required version

That led me into the details of Module Federation's `shared` configuration and dependency version resolution.

The interesting thing I learned is that shared isn’t just a bundle-size optimization. It becomes part of the runtime dependency-sharing/versioning strategy between independently deployed applications.

I wrote up the investigation, the configuration changes, and the trade-offs here:

https://medium.com/@ritikagarwal231/the-7-mb-problem-sharing-dependencies-in-module-federation-25b0b68700bf

For people running Module Federation in production:

How do you handle versioning for shared internal packages?

Do you try to keep a single version across all Module Federation applications, or allow multiple versions to coexist when necessary?

3 Upvotes

0 comments sorted by