“Looking to study, prototype, or structure a project with Micro Frontends (MF) in a modular and high-performance way?”
In recent days, I've delved into an experiment that can greatly simplify the lives of those working with micro frontends daily.
I created an open-source repository using:
- Rsbuild: A modern and fast alternative to Webpack
- Module Federation: To isolate and share components between apps
- pnpm + Lerna: To orchestrate everything in a lightweight and organized manner
A simple yet powerful structure:
-
apps/mf_provider
: exposes components -
apps/mf_consumer
: consumes via Module Federation - All running in parallel with
pnpm dev
Check it out, and if you like it, drop a like or send some feedback!
🔍 A Few Fun Facts
📦 Catalogs
The pnpm
package manager has a really cool feature called Catalogs. It allows you to define dependency versions as constants, which can then be reused inside the package.json
of each internal module.
Example:
# pnpm-workspace.yaml
# Define a catalog of version ranges.
catalog:
react: "^18.3.1"
react-dom: "^18.3.1"
In the internal modules, you can reuse the version defined in pnpm-workspace.yaml
:
"dependencies": {
"react": "catalog",
"react-dom": "catalog"
}
⚙️ Lerna and Parallelism
Another cool thing is how practical Lerna makes it to set up a monorepo. It allows you to run multiple apps in parallel with a single command, like in the example below:
"dev": "lerna run --parallel dev"
✅ Conclusion
Rsbuild + Module Federation turned out to be extremely simple to structure and understand, especially compared to using the plugin with Webpack.
In the next article, I’ll share an example using Vite, so we can get a practical comparison.
See you soon!
Werliton Silva
Frontend Specialist | Bug Hunter | Evangelist of hasOwnProperty()
since 2012
Top comments (5)
Side note, the original Lerna doesn't support pnpm Catalogs but Lerna-Lite does, so Lerna will totally fail when it's time to publish a new release.
Lerna-Lite project, which I maintain, did bring Catalog support a few months ago. As for Lerna, it might take a while, if ever, for them to support pnpm Catalog. Also note that since couple years, Lerna uses and depends on Nx behind the scene (which is large). On the other hand, Lerna-Lite doesn't have any dependency on Nx, and also every commands in Lerna-Lite are optional (separate install) and it's much more lightweight for that reason.
Just wanted to point that out, great article, cheers!
Wow, what a fantastic contribution, man. Thank you so much for bringing that real update. I'll definitely take a close look at Lerna-lite. Thanks
helpful post for frontend developers.
hope to connect with you through discord.
I'm organizing my time, and we'll get in touch via Discord, my friend.
I will wait for it. Thanks 😀