8000 GitHub - kristianmandrup/qiankun: 📦🚀Blazing fast, simple and completed solution for micro frontends.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kristianmandrup/qiankun

 
 

Repository files navigation

qiankun(乾坤)

npm version coverage npm downloads Build Status

In Chinese traditional culture qian means heaven and kun stands for earth, so qiankun is the universe.

An implementation of Micro Frontends, based on single-spa, but made it production-ready.

🤔 Motivation

As we know what micro-frontends aims for:

Techniques, strategies and recipes for building a modern web app with multiple teams using different JavaScript frameworks. — Micro Frontends

Modularity is very important for large application. By breaking down a large system into individual sub-applications, we can achieve good divide-and-conquer between products and when necessary combination, especially for enterprise applications that usually involve multi-team collaboration. But if you're trying to implement such a micro frontends architecture system by yourself, you're likely to run into some tricky problems:

  • In what form do subapplications publish static resources?
  • How does the main application integrate individual sub-applications?
  • How do you ensure that sub-applications are independent of each other (development independent, deployment independent) and runtime isolated?
  • Performance issues? What about public dependencies?
  • And so on...

After solving these common problems of micro frontends, we extracted the kernel of our solution after a lot of internal online application testing and polishing, and then named it qiankun.

Probably the most complete micro-frontends solution you ever met🧐.

📦 Installation

$ yarn add qiankun  # or npm i qiankun -S

📖 Documentation

https://qiankun.umijs.org/

💿 Getting started

This repo contains an examples folder with a sample Shell app and multiple mounted Micro FE apps. To run this app, first clone qiankun

$ git clone git@github.com:umijs/qiankun.git
$ cd qiankun

Now run the yarn scripts to install and run the examples project

$ yarn install
$ yarn examples:install
$ yarn examples:start

Visit http://localhost:7099

Application structure

  • examples/main the main app (shell app that registers and mounts sub-apps)
  • examples/angular9 angular 9 Micro FE app
  • examples/react15 react 15 Micro FE app
  • examples/react16 react 16 Micro FE app
  • examples/vue Vue Micro FE app

Main app

The index.html contains a <main> element which acts as the app container. It references and loads the index.js script file which mounts the main app and Micro frontend apps

<main id="container"></main>
<script src="./index.js"></script>

In index.js the Micro FE apps are registered

registerMicroApps(
  [
    {
      name: 'react16',
      entry: '//localhost:7100',
      render,
      activeRule: genActiveRule('/react16'),
    },

Installing and starting the Shell and Micro FE apps

The examples:install script runs install:* for each script present with an install: prefix, all in parallel The examples:start script runs start:* for each script present with a start: prefix, all in parallel

  "scripts": {
    "examples:install": "npm-run-all --serial build install:*",
    "examples:start": "npm-run-all --parallel start:*",

    "install:main": "cd examples/main && yarn",
    "start:main": "cd examples/main && yarn start",

    "install:react16": "cd examples/react16 && yarn",
    "start:react16": "cd examples/react16 && yarn start",
  }

✨ Features

  • 📦 Based On single-spa
  • 📱 Technology Agnostic
  • 🦾 HTML Entry Access Mode
  • 🛡 Style Isolation
  • 🧳 JS Sandbox
  • Prefetch Assets
  • 🔌 Umi Plugin Integration

🎯 Roadmap

  • Parcel apps integration (multiple sub apps displayed at the same time, but only one uses router at most)
  • Communication development kits between master and sub apps
  • Custom side effects hijacker
  • Nested Microfrontends

❓ FAQ

https://qiankun.umijs.org/faq/

👬 Community

https://qiankun.umijs.org/#community

🎁 Acknowledgements

About

📦🚀Blazing fast, simple and completed solution for micro frontends.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.2%
  • JavaScript 2.8%
0