Create a module federation app
Developed by Jack Herrington, co-author of the "Practical Module Federation" book and technology-focused YouTuber.
create-mf-app is a tool that creates a Module Federation application, API server, or library based on one of multiple different templates.
Generating Application
This guide provides a comprehensive walkthrough on how to use the create-mf-app tool to create a Module Federation application and integrate it with Zephyr.
To execute npm package binaries, use the npx command as follows:
Choose a name for your application. Ensure you designate one host and at least one remote, choosing names that reflect their roles accordingly.
Select the type of application:
You may use the default port option:
We conducted tests using React, but other frameworks may also be compatible. See the Module Federation guide for more details on supported frameworks.
We prefer TypeScript, but Zephyr is compatible with both TypeScript and JavaScript.
Both CSS and Tailwind are viable options for styling:
While both packing options are viable, we strongly recommend Rspack for its performance. See benchmark of Rspack.
Adding Zephyr to Your Module Federation App
Installing Zephyr plugin:
For Rspack:
For Webpack:
Zephyr Configuration Integration
Incorporate the Zephyr configuration into your existing setup by wrapping the current configuration object with Zephyr's functionality.
Setting up Git Repository
Zephyr requires a Git repository to track your project. Follow these steps to set up your repository:
- Initialize the Git Repository:
- Stage Files for Commit:
- Create an Initial Commit:
- Set the Default Branch:
- Create and Link Remote Repository:
- Push to Remote:
Build and Deploy
Build your application to deploy it with Zephyr:
During the build process, Zephyr will:
- Extract your Module Federation configuration
- Upload your built assets to Zephyr Cloud
- Provide you with deployment URLs
Your application will be automatically available at the provided Zephyr URL. Each deployment creates a new version of your application with its own permanent URL.
Next Steps
- Create additional remote applications using
create-mf-app - Configure Module Federation relationships between your apps
- Explore Module Federation patterns
- Learn about version management
For more insights on building micro-frontends with Module Federation, check out Jack Herrington's video tutorial.