Giter Club home page Giter Club logo

Comments (9)

2heal1 avatar 2heal1 commented on August 30, 2024 1

Yes, i will support shared can pass array to support register mulite version shared in next days

from universe.

ScriptedAlchemy avatar ScriptedAlchemy commented on August 30, 2024

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.

ScriptedAlchemy avatar ScriptedAlchemy commented on August 30, 2024

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.

MadaraUchiha-314 avatar MadaraUchiha-314 commented on August 30, 2024

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.

@ScriptedAlchemy ^

from universe.

ScriptedAlchemy avatar ScriptedAlchemy commented on August 30, 2024

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.

MadaraUchiha-314 avatar MadaraUchiha-314 commented on August 30, 2024

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.

ScriptedAlchemy avatar ScriptedAlchemy commented on August 30, 2024

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

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.

zackarychapple avatar zackarychapple commented on August 30, 2024

@ScriptedAlchemy @2heal1 I think this is wrapped up right? I remember seeing a PR around it.

from universe.

ScriptedAlchemy avatar ScriptedAlchemy commented on August 30, 2024

yes this should be complete

from universe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.