webpack / webpack

A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
https://webpack.js.org
MIT License
64.55k stars 8.77k forks source link

Is it possible for webpack module federation to support multiple versions of a singleton library running? #16042

Closed sabeekaq closed 2 years ago

sabeekaq commented 2 years ago

So currently I have the following architecture:

Currently, the only way the component library can work with the current setup is if we declare it as a singleton (I believe this was needed for theming and sharing state). However, for our use case this is not scalable as teams working on different apps may not want to upgrade their version of the component library at the same time as other apps. Therefore, we may need multiple versions of the component library running at the same time.

Is it possible for webpack module federation to support multiple versions of a singleton library running?

alexander-akait commented 2 years ago

Therefore, we may need multiple versions of the component library running at the same time.

In theory - yes, but I don't think it is a good idea, you will have an extra runtime (and not) code, you can look at the source code and rewrite it in hooks or just in assets using regexp/etc. Don't think we should include this into core.

vankop commented 2 years ago

Is it possible for webpack module federation to support multiple versions of a singleton library running?

it is not same anymore.. I think no.. maybe you need to change versioning in this case e.g. use new naming my-library-next, my-library-beta instead of version

ScriptedAlchemy commented 2 years ago

Put it under another share scope

sabeekaq commented 2 years ago

@ScriptedAlchemy - are you referring to this? It is a bit confusing what it is trying to do, could you please provide some more context?

ScriptedAlchemy commented 2 years ago

Look up advanced api module federation. I wrote a medium article a few years ago about some of the share options.