GithubHelp home page GithubHelp logo

odikusar / multi-framework-module-federation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ilya-isupov/multi-framework-module-federation

0.0 0.0 0.0 1.22 MB

This code is about approach to dynamically use Webpack Module Federation plugins implemented by different frameworks (angular, react, vue)

JavaScript 15.23% TypeScript 46.39% HTML 29.80% Vue 3.40% Less 5.18%

multi-framework-module-federation's Introduction

Multi framework module federation technical example

This project is full e2e example about ability using angular/react/vue in one application base on Module Federation.

Development server

Run yarn deps:all to install all dependencies. Run yarn start:all to start all microfrontends and host application by one button press.

Example consist of: host (angular 11), several angular plugins (angular 11, 12), several react plugins and vue plugin.

How to move to module federation plugin bundling (Angular)

  1. Add resolution field to package.json

"resolutions": {"webpack": "^5.0.0"}

  1. Set yarn package manager default for project

ng config cli.packageManager yarn

  1. Add @angular-architects/module-federation package. It will automatically add config-overrides.js and other settings needed to use module federation

ng add @angular-architects/module-federation

  1. After that configure partially configuration for config-overrides.js Example for remote plugin
const webpack = require("webpack");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const dependencies = require("./package.json").dependencies;

module.exports = {
      output: {
          uniqueName: "angular_mfe_1",
      },
      optimization: {
          runtimeChunk: false,
      },
      plugins: [
          new ModuleFederationPlugin({
              name: "angular_mfe_1",
              library: {type: "var", name: "angular_mfe_1"},
              filename: "remoteEntry.js",
              exposes: {
                  MfeModule: "./src/app/modules/business-module/business.module.ts",
              },
              shared: {
                  '@angular/common/http': {
                      version: dependencies['@angular/common'],
                      requiredVersion: dependencies['@angular/common'],
                      singleton: true,
  
                  },
                  '@angular/common': {
                      version: dependencies['@angular/common'],
                      requiredVersion: dependencies['@angular/common'],
                      singleton: true,
  
                  },
                  '@angular/core': {
                      version: dependencies['@angular/core'],
                      requiredVersion: dependencies['@angular/core'],
                      singleton: true,
  
                  },
                  '@angular/platform-browser': {
                      version: dependencies['@angular/platform-browser'],
                      requiredVersion: dependencies['@angular/platform-browser'],
                      singleton: true,
  
                  },
                  '@angular/platform-browser-dynamic': {
                      version: dependencies['@angular/platform-browser-dynamic'],
                      requiredVersion: dependencies['@angular/platform-browser-dynamic'],
                      singleton: true,
  
                  },
                  '@angular/router': {
                      version: dependencies['@angular/router'],
                      requiredVersion: dependencies['@angular/router'],
                      singleton: true,
  
                  },
                  '@angular/cdk/a11y': {
                      version: dependencies['@angular/cdk/a11y'],
                      requiredVersion: dependencies['@angular/cdk/a11y'],
                      singleton: true,
  
                  },
                  '@angular/animations': {
                      version: dependencies['@angular/animations'],
                      requiredVersion: dependencies['@angular/animations'],
                      singleton: true,
  
                  }
              }
          })
      ],
  };

multi-framework-module-federation's People

Contributors

krylovsentry avatar ilya-isupov avatar whitecrossxd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.