React Typescript Module Federation screenshot

React Typescript Module Federation

Author Avatar Theme by Ogzhanolguncu
Updated: 10 Nov 2022
180 Stars

Micro Frontend with React, ReactRouter V6, Typescript and Webpack

Categories

Overview

This project is a demonstration of using Webpack 5 Module Federation with React and Typescript. It consists of a host app container and two remote apps, app1 and app2. The workflow involves app1 exposing a CounterAppOne component and app2 exposing a CounterAppTwo header component. The container then imports and uses these components. To run the demo, the author recommends installing Lerna globally and running a command in the project’s root directory. The demo can be accessed through the following URLs: http://localhost:3000/ (container), http://localhost:3001/ (app1), and http://localhost:3002/ (app2). The tech stack used includes React, Typescript, Chakra UI, Webpack, Lerna, and React Router V6.

Features

  • Webpack 5 Module Federation integration
  • Host app container with two remote apps
  • Exposing and importing React components
  • Parallel execution of multiple projects using Lerna
  • Integration with React Router V6

Installation

To install and run this project, follow the steps below:

  1. Install Lerna globally by running the following command in your terminal:

    npm install --global lerna
    
  2. Clone the project repository and navigate to the root directory.

  3. Install the project dependencies by running the following command:

    lerna bootstrap
    
  4. Start all the projects in parallel by running the following command:

    lerna run start
    
  5. Open your browser and access the following URLs to see the running demo:

    • http://localhost:3000/ (container)
    • http://localhost:3001/ (app1)
    • http://localhost:3002/ (app2)

Summary

This project demonstrates the usage of Webpack 5 Module Federation with React and Typescript. It showcases the integration of a host app container with two remote apps, allowing for the exposure and importation of React components. The project also utilizes Lerna for parallel execution of multiple projects and incorporates React Router V6 for routing. Overall, this serves as a useful template for building micro frontends with Module Federation. If you have any feedback or encounter any issues, you are encouraged to reach out to the author or open an issue.