cl-craft v1.0.11
cl-craft
cl-craft is a command line tool that helps you get started quickly building a Microfrontends project using Webpack's Module Federation plugin and React as the frontend framework.
Description
npx cl-craft [command] [project type] [options]
This is the list of available commands:
- help: Shows this help
- create-mf: Creates a new microfrontend project (container or remote)
This is the list of available project types:
- container: A container project
- remote: A remote project that gets included into the container
This is the list of available options:
- -d, --deploy: Generates the deploy script
NOTE: A microfrontend project is comprised of a container and one or more remote projects.
Usage
- Go to the folder in which you wish to create your project.
- Run
npx cl-craft create-mf containerand follow the instructions. - Run
npx cl-craft create-mf remoteand follow the instructions.
The previous commands create the folders and files and installs dependencies. After creating your container and your remotes go to each project folder and run npm start.
What you get
After you create a container and a remote you'll get the following:
- A
containerproject that injects theremoteproject on run time. - Global routing on the
containerto navigate among theremoteprojects. - A
remotespecific routing system. - A global state using React Context, managed by the
container. Theremoteproject has access to it via thecontextprop. - Basic tests and the test suite configured.
- Support for dotenv.
- If you pass the option to deploy (
-dor--deploy), the Github Worflow files for each project.
Visual representation

Known pitfalls
React Context
For managing a global state we use React Context which comes with React v16. If you can't use v16, you can use workarounds like:
- Storing shared data in localStorage
- Requesting the data from a shared API
Webpack
We're using Webpack 5, so things you have currently in your projects might not work. You need to check out the Webpack docs to see how to fix the issues.