-
Notifications
You must be signed in to change notification settings - Fork 94
Description
Describe the bug
Hi team. We are running into significant initial load time and bundle size issues after migrating a large micro-frontend application from Webpack Module Federation to Vite using this plugin, and we would like to understand whether:
- This is expected behaviour for our architecture
- We might be misconfiguring something, or
- There are recommended optimizations we are missing
Our setup (simplified):
- Host application
- 9 remotes all using Vite (more expected in the future)
- One remote acts as a shared/common library used by host and most of the remotes
- All applications are React based
- All applications are using @module-federation/vite
Observed Issue
After migration,
- Initial page load increased significantly (~ half a min)
- Bundle size increased noticeably
- Network tab shows a large number of JS requests and many small chunks. Some of them are of the kind __loadShare__react__loadShare for every remote loaded. Also, the shared MFE has a similar loadRemote for every remote using it
- Giving singleton and required version to shared dependencies makes the application reload infinitely
What we have already tried
- Ensured react and react-dom are shared and on same versions in all the applications
- Lazy load remotes
Host config (simplified)
export default defineConfig(({ mode }) => {
return {
...
plugins: [
react(),
tsconfigPaths(),
federation({
name: env.REACT_APP_NAME,
filename: 'remoteEntry.js',
exposes: {},
remotes: {
remote1: {
type: 'module',
name: 'remote1',
entry: <remote 1 entry url>
},
remote2: {
type: 'module',
name: 'remote2',
entry: <remote 2 entry url>
},
.....
},
shared: Object.keys(deps),
}),
],
build: {
target: 'esnext',
modulePreload: false,
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext',
loader: {
'.js': 'jsx',
},
},
exclude: ['@module-federation/vite'],
},
};
});
Network tab screenshot with JS filtered
We would really appreciate guidance on:
- Whether this initial load cost is expected for a setup of this size
- Recommended performance best practices for large MF systems with Vite
- Whether there are known bundle size or runtime overhead limitations
- Any suggestions for reducing request count/chunk waterfalls
About reproduction
We understand that a minimal reproduction is usually preferred, however a truly representative reproduction would require multiple remotes with a shared remote as well. Please let us know what level of reproduction would be most useful.
Thanks in advance for your time and help. We really want to make this setup work well at scale.
Version
7.1.11
Reproduction
https://github.com/aryavgopal/vite-mfe-sample
Relevant log output
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.