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.
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 a list of supported framework here
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.
Installing Zephyr plugin:
Incorporate the Zephyr configuration into your existing setup by wrapping the current configuration object with Zephyr's functionality. To use zephyr-webpack-plugin with Rspack, replace the original content in rspack.config.js
with:
Initialize the Git repository to start tracking your project:
Add all files to the staging area in preparation for the initial commit:
Commit the staged files to your repository with a descriptive message:
Define 'main' as the default branch for your repository:
User
and UserRepo
with your GitHub username and repository name (You can download Github CLI here):Optionally, you can push your code to GitHub to store your changes remotely:
If you encounter errors due to unset Git configurations, ensure you have set both your Git user.name
and user.email
, and that you have a valid 'git remote origin' set up.
If this error show up - create a new repository and copy the link to that repository, do:
Zephyr operates as a side effect of the build process, allowing you to execute the build in watch mode for continuous updates.
The first time you initiate a build with Zephyr, it will prompt you to log in by directing you to the Zephyr website. This login is required only on your first build; subsequent builds will not require a login.
We may require you to log in again if you removed your Zephyr configuration file ~/.zephyr
locally.
During the build process, Zephyr related informations are displayed as follows:
To understand how our URLs are structured, please refer to our versioning documentation.
> npm run build
(6%)
setup before compile
(59%)
building css|node_modules/postcss-loader/dist/cjs.js??ruleSet[1]
(62%)
sealing finish modules
uploading missing assets to zephyr (queued 2 out of 7)
Uploaded missing assets to zephyr (2 assets in 300ms, 5.74kb)
(98%)
emitting emit
Uploaded local snapshot in 193ms.
Build deployed in 195ms.
Deployed to edge:
(100%)
done
Rspack compiled successfully in 892ms
You can now proceed to add remotes and start building your federated application as planned.
For insights on building micro-frontends with Rspack and Create MF App, Jack offers an informative video tutorial. We have also curated a resource page related to micro-frontend and module federation here.