Choose between a Webpack-based and a Vite-based solution for Module Federation.
We recommend using the solutions in a Platforms setup, to enjoy an excellent developer experience.
Make sure to run the following commands inside a Bit workspace.
The following steps will guide you through setting up a Webpack-based Module Federation project.
To learn more about configuring the apps, building and deploying them, refer to Bit's Webpack Module Federation app-type documentation.
A platform app orchestrates the host and remote apps (as well as possible micro services). Run the following to fork a platform app and set it as an app in your workspace:
Run the following to run the platform app locally:
When you run the platform app, it automatically runs the host and remote apps.
Run the following to fork a remote module:
Steps for a platforms setup
Replace the current 'reactions' import statement in the mf-platform.bit-app.tsx
file with the following:
/** * @filename: mf-platform.bit-app.tsx */ // REPLACE THIS WITH THE FORKED COMPONENT PACKAGE NAME const Reactions = import.meta.resolve('@bitdev/react.examples.reactions-mf');
Steps for a non-platforms setup
Run the following to set the component as an app in your workspace and run it locally (you can skip this step if you are using a platform setup):
Run the following to fork a host app and set it as an app in your workspace:
Steps for a platforms setup
Replace the current 'reactions' import statement in the mf-platform.bit-app.tsx
file with the following:
/** * @filename: mf-platform.bit-app.tsx */ // REPLACE THIS WITH THE FORKED COMPONENT PACKAGE NAME const MonstersUI = import.meta.resolve('@bitdev/react.examples.monsters-ui');
Steps for a non-platforms setup
Run the following to set the component as an app in your workspace and run it locally (yuu can skip this step if you are using a platform app):
The following steps will guide you through setting up a Vite-based Module Federation project.
To learn more about configuring the apps, building and deploying them, refer to Bit's Vite Module Federation app-type documentation.
A platform app orchestrates the host and remote apps (as well as possible micro services). Run the following to fork a platform app and set it as an app in your workspace:
Run the following to run the platform app locally:
When you run the platform app, it automatically runs the host and remote apps.
Run the following to fork a remote module:
Steps for a platforms setup
Replace the current 'reactions' import statement in the platform.bit-app.tsx
file with the following:
/** * @filename: platform.bit-app.tsx */ // REPLACE THIS WITH THE FORKED COMPONENT PACKAGE NAME const Reactions = import.meta.resolve('@bitdev/react.examples.vite-reactions');
Steps for a non-platforms setup
Run the following to set the component as an app in your workspace and run it locally (you can skip this step if you are using a platform setup):
Run the following to fork a host app and set it as an app in your workspace:
Steps for a platforms setup
Replace the current 'reactions' import statement in the platform.bit-app.tsx
file with the following:
/** * @filename: platform.bit-app.tsx */ // REPLACE THIS WITH THE FORKED COMPONENT PACKAGE NAME const MonstersUI = import.meta.resolve( '@bitdev/react.examples.vite-monsters-ui' );
Steps for a non-platforms setup
Run the following to set the component as an app in your workspace and run it locally (you can skip this step if you are using a platform app):