-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Description
Steps to reproduce
I've created a simple repo to reproduce my issue:
https://github.com/nate-summercook/test-mf-mui-project
Follow the steps from the readme.
Current behavior
Uncaught (in promise) TypeError: _emotion_styled__rspack_import_0 is not a function
no matter what I've put in the shared section of my module federation configuration, I couldn't get rid of this error.
Expected behavior
No errors and working MF 🙃
Context
In a project I'm working on, we're using React 18 (not migrated to 19 yet), MUI 6 and Module Federation (1.5) with rsbuild. This setup works and we don't have issues currently.
In the process of migrating MUI 6 to MUI 7 we encountered issues with shared modules in Module Federation:
Uncaught (in promise) TypeError: _emotion_styled__rspack_import_0 is not a function
We've tried many things: Changing the shared dependencies definition in the module federation configuration in all kinds of ways, migrating to Module Federation 2.0, etc. Nothing helped, also all kinds of AI tools were clueless on how to solve it.
Since it worked with MUI 6, I suspect it has something to do with MUI switching to an esm bundle. I suspect there's currently no way to use MUI 7 in a module federation context and here's my minimal project to try and prove that point.
Your environment
npx @mui/envinfo
System:
OS: macOS 26.2
Binaries:
Node: 24.11.0 - /Users/***/.volta/tools/image/node/24.11.0/bin/node
npm: 11.6.1 - /Users/***/.volta/tools/image/node/24.11.0/bin/npm
pnpm: Not Found
Browsers:
Chrome: 143.0.7499.110
Edge: 143.0.3650.80
Firefox: 146.0.1
Safari: 26.2
npmPackages:
@emotion/react: 11.14.0
@emotion/styled: 11.14.1
@mui/core-downloads-tracker: 7.3.6
@mui/material: 7.3.6
@mui/private-theming: 7.3.6
@mui/styled-engine: 7.3.6
@mui/system: 7.3.6
@mui/types: 7.4.9
@mui/utils: 7.3.6
@types/react: 18.3.27
react: 18.3.1
react-dom: 18.3.1
typescript: 5.9.3
Search keywords: mui7, module federation, mf