Skip to content

Material-ui/lab and material-ui/pickers overriding styles when being imported from remote federated modules #1071

Closed
@jmelendez-cbs

Description

@jmelendez-cbs

We are using webpack 5 and a design system that hosts federated modules from material ui. As of now we have the following setup for the ModuleFederationPlugin.

    new ModuleFederationPlugin({
      name: 'rosters-web-app',
      // TODO: Make optional depending if the DS is running locally
      remotes: {
        'dataeng-ds': federationUrl
      },
      shared: {
        ...pkgJson.dependencies,
        "@material-ui/core": {
          singleton: true,
        },
        react: { 
          singleton: true, 
          requiredVersion: pkgJson.dependencies.react 
        },
        "react-dom": { 
          singleton: true, 
          requiredVersion: pkgJson.dependencies["react-dom"] 
        }
      },
    })

This is how a page on the app displays:

Screen Shot 2021-08-05 at 11 51 56 AM

However, when we use a component from material-ui/lab or material-ui/pickers it seems the styles get messed up.

Notice the buttons are now unstyled/overwritten

Screen Shot 2021-08-05 at 11 53 44 AM

Does anyone have an idea on why this is happening?

Note: I have also tried adding

      "@material-ui/lab": {
          singleton: true,
        },

to the shared list and it still does not work.

Screen Shot 2021-08-05 at 12 04 59 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions