Comments (9)
Yes, i will support shared can pass array to support register mulite version shared in next days
from universe.
A custom runtime plugin that uses resolveShare should work.
IF react is set to a singleton its going to always fetch the highest version within the semver requirements. Unless set singleton: false or use strictVersion etc.
from universe.
if you look in share_scope object, it should register all version keys available but will return the version based on the rules of federation semver algo, unless you override it with your own in resolve share
from universe.
A custom runtime plugin that uses resolveShare should work.
IF react is set to a singleton its going to always fetch the highest version within the semver requirements. Unless set singleton: false or use strictVersion etc.
The problem is not with resolving to the right version of the package. The problem is how do we register multiple versions of the same package from a single container ?
Within a single container, due to nested dependencies, there might be many different versions of the same package that might be resolved. When a bundler plugin implementing module-federation is rewriting those imports to loadShare
, it needs to provide the version info so that the correct version is resolved.
For federation runtime to resolve the correct version, it needs the ability to register multiple version of the same package during the init
call. That's what's missing.
from universe.
use a trailing slash
react/
for instance, that should register any dependency that starts with react/ request, not just resolve to index file.
from universe.
I am still not able to grasp it completely 😅 May be if you could provide an example that would help me understand it better ?
My use case (as I mentioned in the parent post) is that of a plugin which is trying to implement module federation for a bundler (in this case rollup).
May be we can connect and I can explain this issue better.
from universe.
Ahh i understand what you mean.
The only way id seen this done in webpack was via the trailing slash which did some magic under the hood, and it adds multiple keys under the library for each version.
![image](https://private-user-images.githubusercontent.com/25274700/317087793-04f0c2dc-56d3-42e5-95d4-ab35e52aac2f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ5NzY1OTYsIm5iZiI6MTcyNDk3NjI5NiwicGF0aCI6Ii8yNTI3NDcwMC8zMTcwODc3OTMtMDRmMGMyZGMtNTZkMy00MmU1LTk1ZDQtYWIzNWU1MmFhYzJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMwVDAwMDQ1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ5NzQ1ZTg4ZDBlZTNkMTFmNmJlNTAyM2RjMGFkNGFmZDhmZTY0MDgxYjVhZWMyNjliNGUwNzNiYzJmOWVkMzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.SU6dRxT1tVdIvGmwMvd0OEtCtPHAdmqnUIi_M9ru1_I)
In here i only have one, but if there were more they would register here as additional keys.
@2heal1 do you have any suggestions?
We could allow for array support in the share, so you could pass an array of different react versions etc.
init({
name: '@demo/main-app',
remotes: [],
shared: {
react: [
{
version: '17.0.0',
scope: 'default',
lib: () => require('react'),
shareConfig: {
singleton: true,
requiredVersion: '^17.0.0',
},
},
{
version: '18.0.0',
scope: 'default',
lib: () => require('../modern/react'),
shareConfig: {
singleton: true,
requiredVersion: '^18.0.0',
},
},
],
'react-dom': {
version: '17.0.0',
scope: 'default',
lib: () => ReactDOM,
shareConfig: {
singleton: true,
requiredVersion: '^17.0.0',
},
},
},
});
from universe.
@ScriptedAlchemy @2heal1 I think this is wrapped up right? I remember seeing a PR around it.
from universe.
yes this should be complete
from universe.
Related Issues (20)
- `errorLoadRemote` doesn't trigger HOT 2
- @mf-types.zip not being generate since 0.2.7 HOT 6
- Federation Runtime can't use SDK function while running at Nextjs HOT 3
- Feature: MFE import functions HOT 5
- Federation Runtime not sharing same react context HOT 12
- React with Web Worker Error HOT 1
- [ Federation Runtime ]: The remote "app" is already registered. If you want to merge the remote, you can set "force: true". HOT 3
- Issue: Incomplete Type Generation with DTS Plugin in module-federation/enhanced HOT 1
- Docs: Users need documentation on common errors when starting with module-federation HOT 1
- Navigation cross remotes get 404 HOT 1
- `runtimePlugin_js__WEBPACK_IMPORTED_MODULE_1__ is not a function` HOT 1
- Docs: why does the example for the button producer not use a <button> tag? HOT 1
- Module not found: Error: Can't resolve './named-references' HOT 2
- enableImageLoaderFix in next-mf doesn't work for non-root remotes
- Request: Federation Runtime CSS asset Link insert hook HOT 4
- Seeing the dreaded ` ⨯ TypeError: Cannot read properties of undefined (reading 'call')` error again with NextJS HOT 2
- @module-federation/native-federation-typescript doesn't create remoteEntry.js upon build for vite and rspack
- '[email protected]' is not in this registry
- @mfe-types are not regenerated HOT 1
- Getting react hooks error in the host application - Cannot read properties of null (reading useEffect)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universe.