Micro Frontends - Module federation with Nx

Overview

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

juicy-mfe

Module Federation을 이용한 Micro Frontend(마이크로 프론트엔드) 아키텍쳐 Monorepo 연습장 입니다.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

image image image

Micro Frontend

(back to top)

Built With

(back to top)

Getting Started

graph

MFE(Micro Frontend)를 구현하는 방법은 다양 합니다 (빌드타임 통합, iframe, 웹뷰 등). 본 프로젝트는 그 중 런타임에 애플리케이션(번들)들이 통합 될 수 있는 webpack5의 module federation을 이용합니다. nx의 플러그인을 활용하여 빠르게 Module Federation MFE를 구현하는 예제 입니다.

  • [Host]

    • host - (port: 4200)
  • [Remotes]

    • app1 - (port: 4201)
    • app2 - (port: 4202)
    • header - (port: 4203)
  • [Shared Library]

    • shared/components
    • shared/utils
  • Host, Remotes 앱은 각각 독립적으로 실행이 가능하며 런타임에 통합될 수 있습니다.

    • 즉, 수정 사항이 발생한 앱만 빌드 및 배포 하여도 해당 앱을 사용하는 Host 앱들은 빌드, 배포가 필요하지 않습니다.
  • 공통으로 사용되는 라이브러리들은 빌드 타임에 통합합니다.

Prerequisites

pnpm

workspace.json에서 프로젝트 네임 확인

Installation

  1. repo를 clone한다.
    git clone https://github.com/juicyjusung/juicy-mfe.git
  2. pacakges 설치한다.
    cd juicy-mfe
    pnpm install

(back to top)

Usage

서버 실행

nx serve [앱]

// 호스트 serve
nx serve host

// 리모트 개발 서버 
nx serve host --open --devRemotes=app1,app2

테스트 (unit/E2E)

unit test

nx test [프로젝트(앱/라이브러리)명]

nx test host
nx test app1

// watch option
nx test host --watch
nx test shared-components --watch

// many
nx run-many --target=test --all
nx run-many --target=test --projects=app1,app2
nx run-many --target=test --projects=app1,app2 --parallel=2

e2e test

nx e2e [프로젝트(앱/라이브러리)명]

// Headless Mode
nx e2e host-e2e

// Headed Mode
nx e2e app1-e2e --watch

// Testing Against Prod Build
nx e2e host-e2e --prod

// many
nx run-many --target=e2e --all
nx run-many --target=e2e --projects=app1-e2e,app2-e2e

project, lib 추가

앱 추가

[Module Federation]
// host 추가 (react)
nx g @nrwl/react:host host --remotes=shop,cart,about

// remote 추가 (react)
nx g @nrwl/react:remote shop --host=host

라이브러리 추가

nx g lib [라이브러리 명]

// ex) 리액트 라이브러리 추가
nx g @nrwl/react:library shared/ui

라이브러리 삭제

nx g remove [라이브러리 명]

nx g remove [라이브러리 명] --forceRemove

// ex
nx g remove shared-ui

빌드

nx run-many --target=build --all

Graph

graph

nx graph

CI

코드 수정에 따라 영향을 받는 프로젝트만 lint, test, build, e2e 를 진행합니다.

(back to top)

Roadmap

  • 스토리북 추가
  • 다른 프레임웤/라이브러리(Vue, Angular 등) 추가
  • deploy

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contact

juicyjusung - [email protected]

Project Link: https://github.com/juicyjusung/juicy-mfe

(back to top)

You might also like...

distributed-nginx nginx k8s docker micro front-end

distributed-nginx (分布式 nginx) 🍙 适用于微前端的去中心化分布式部署 nginx 服务器. 特性 支持 前端服务上线下线 自动更新微前端模块配置 完全实现了分布式去中心化 支持【微前端组】 支持 redis 协议和 multicast-dns 协议 支持 命名空间 Ge

Feb 25, 2022

DIY Presentation Micro-Framework

Bespoke.js DIY Presentation Micro-Framework Bespoke.js is a super minimal (1KB min'd and gzipped), modular presentation library for modern browsers, d

Dec 18, 2022

Fast & Robust Front-End Micro-framework based on modern standards

Chat on gitter Hello slim.js - your declarative web components library import { Slim } from 'slim-js'; import { tag, template } from 'slim-js/decorato

Dec 30, 2022

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.

Atomico simplifies learning, workflow and maintenance when creating webcomponents. Scalable and reusable interfaces: with Atomico the code is simpler

Dec 31, 2022

Micro is coming back!

Micro is coming back!

Micro Micro is being remade! The core team currently consists of: Modded Minota Edaz Levi Ashton but we welcome contributions from anyone! You can hav

Jan 1, 2023

A docker container with a wide variety of tools for debugging and setting up micro-services

Frame One Software Placeholder There are numerous times during the dev ops deployments, that a placeholder container is needed. In the past, Frame One

May 29, 2022

Arquitetura que possa vir a ser utilizada para um micro serviço em nodejs com nestjs e typescript

Descrição Exemplo prático de uma API desenvolvida em NodeJs com NestJs e Banco de Dados Postgres Instalação Instalando as dependencias $ npm install

Jan 11, 2022

Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist 📚 📓 📒 📖 🔖 The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Dec 13, 2022

An app for spinning up social media micro-platforms.

Note: This project is super early. It's not in a usable state at this point. Though I'm working on this full-time, and it's moving ahead at a fast pac

Oct 21, 2022
A module federation SDK which is unrelated to tool chain for module consumer.

hel-micro, 模块联邦sdk化,免构建、热更新、工具链无关的微模块方案 Demo hel-loadash codesandbox hel-loadash git Why hel-micro 如何使用远程模块 仅需要一句npm命令即可载入远程模块,查看下面例子线上示例 1 安装hel-micr

腾讯TNTWeb前端团队 319 Jan 3, 2023
This is an example project to demonstrate how to use Nx, Next.js and Module Federation together.

Nextjs, Nx and Module Federation This is an example project to demonstrate how to use Nx, Next.js and Module Federation together. ⚠ This example depen

Bruno Silva 14 Nov 28, 2022
Micro.publish is an Obsidian plugin to publish notes directly to Micro.blog, written in TypeScript

Micro.publish Micro.publish is a community maintained plugin for Obsidian to publish notes to a Micro.blog blog. Installing This plugin will be availa

Otavio Cordeiro 14 Dec 9, 2022
🛠 Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

?? Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

Holaplex 30 May 21, 2022
GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schemas (Federation, Stitching)

GraphQL Hive GraphQL Hive provides all the tools the get visibility of your GraphQL architecture at all stages, from standalone APIs to composed schem

Kamil Kisiela 184 Dec 21, 2022
An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

Snyk Labs 57 Dec 28, 2022
Fintoc.js ES Module - Use the Fintoc widget as an ES module

Fintoc.js ES Module Use the Fintoc widget as an ES module. Installation Install using npm! (or your favourite package manager) # Using npm npm install

Fintoc 6 May 13, 2022
Template Repository for making your own budder Module. CORE is not included, this is just for the module.

A quick copy of the "How to make your own module" section Check out the official budderAPI repository Template Repository for making your own budder M

Logic 2 Apr 3, 2022
Userland module that implements the module path mapping that Node.js does with "exports" in package.json

exports-map Userland module that implements the module path mapping that Node.js does with "exports" in package.json npm install exports-map Usage co

Mathias Buus 9 May 31, 2022