Giter Club home page Giter Club logo

module-federation-demo's Introduction

Webpack 5 Module Federation 方式对 MotorSDK 独立更新

ProjA 是依赖 ProjBCommon ProjBCommon 可以是 MotorSDK 或者其他的公共库

ProjBCommon 向外暴露 MotorSDK

当用户需要更新 MotorSDK 仅仅把 MotorSDK 包更新到 ProjBCommon 中即可,重新打包 ProjBCommon 即可 只要 ProjBCommon 不改变 MotorSDK 的包名,没有修改API,新增API,用户就不需要重新编译 ProjA

ProjBCommon 用户仅仅是打包,部署到自己的私服中,供 ProjA 使用即可

ProjA

需要配置 ProjBCommon 的地址 需要配置 MotorSDK 的 BaseUrl

ProjBCommon

每次更新之后 pnpm build 发布到自己的服务器即可 两种方式,一个是用 Luban 生成的 Build ,一个是自己下载自己配置的 webpack.config.js 进行打包

使用方式

cd ProjBCommon
pnpm install 
pnpm build
cd dist
npx serve -p 3001 -C
# http://localhost:3001/remoteEntry.js // module federation 访问地址 可以随意部署到服务器的任意目录下,只要能访问到即可


cd ProjA
pnpm install
pnpm start
#ProjA/webpack.config.js
# 配置好上面 ProjBCommon 的地址

module-federation-demo's People

Watchers

Prophet 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.