All Projects → unadlib → fronts

unadlib / fronts

Licence: MIT license
A progressive micro frontends framework for building Web applications

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to fronts

micro-frontend-gateway
🌐 Micro Frontends PoC in Angular - GATEWAY
Stars: ✭ 26 (-94.73%)
Mutual labels:  micro-frontends, microfrontends
Microfrontends
Micro-frontend Architecture in Action-微前端的那些事儿
Stars: ✭ 2,696 (+446.86%)
Mutual labels:  micro-frontends, microfrontends
scalecube-js
Toolkit for working in microservices/micro-frontends architecture.
Stars: ✭ 63 (-87.22%)
Mutual labels:  micro-frontends, microfrontends
Single Spa
The router for easy microfrontends
Stars: ✭ 10,395 (+2008.52%)
Mutual labels:  front-end, microfrontends
Qiankun
📦 🚀 Blazing fast, simple and complete solution for micro frontends.
Stars: ✭ 11,497 (+2232.05%)
Mutual labels:  micro-frontends, microfrontends
rallie
a library that helps users implement decentralized front-end micro service architecture
Stars: ✭ 285 (-42.19%)
Mutual labels:  microfrontends, module-federation
nut
🌰 A framework born for micro frontends
Stars: ✭ 101 (-79.51%)
Mutual labels:  microfrontends
missionlog
🚀 lightweight logging • supports level based filtering and tagging • weighs in at around 500 bytes
Stars: ✭ 19 (-96.15%)
Mutual labels:  front-end
front-end-responsibilities
A laundry list of possible front-end engineering responsibilities
Stars: ✭ 39 (-92.09%)
Mutual labels:  front-end
jigjs
🧩 A front-end framework
Stars: ✭ 22 (-95.54%)
Mutual labels:  front-end
front-end-interview-guide
前端面试手册,含JS,HTML,CSS,算法和数据结构,计算机系统,计算机网络,浏览器,性能优化,前端工程化,数据库,前端框架,小程序,设计模式,数据可视化
Stars: ✭ 42 (-91.48%)
Mutual labels:  front-end
purescript-pop
😃 A functional reactive programming (FRP) demo created with PureScript events and behaviors.
Stars: ✭ 33 (-93.31%)
Mutual labels:  front-end
fakey-json
This is a utility for mocking json data that pretends the api response data with JSON format.
Stars: ✭ 27 (-94.52%)
Mutual labels:  front-end
hocus-focus
A keyboard navigation horror game.
Stars: ✭ 70 (-85.8%)
Mutual labels:  front-end
glitched-writer
Glitched, text writing js module. Highly customizable settings. Decoding, decrypting, scrambling, or simply spelling out text.
Stars: ✭ 51 (-89.66%)
Mutual labels:  front-end
react-native-header-search-bar
Fully customizable header search bar for React Native
Stars: ✭ 101 (-79.51%)
Mutual labels:  front-end
blog
No description or website provided.
Stars: ✭ 20 (-95.94%)
Mutual labels:  front-end
tags
HTML tags in Go
Stars: ✭ 50 (-89.86%)
Mutual labels:  front-end
billing-form
Demo page for user-friendly billing form features
Stars: ✭ 23 (-95.33%)
Mutual labels:  front-end
savjeecoin-frontend
Angular app to visualize & interact with a blockchain
Stars: ✭ 55 (-88.84%)
Mutual labels:  front-end

Fronts Logo


Node CI npm version license

Fronts is a progressive micro frontends framework for building Web applications, and it's based on the module federation of Webpack.

Motivation

Among the many micro frontends solutions, single-spa and Module Federation are the best of them.

single-spa is a micro frontends framework based on router configuration. The centralization of configuration brings some limitations, such as it is difficult to granulate nestable micro frontends, module granularity control, module sharing, and so on.

In 2019, Zack Jackson proposed and implemented Module Federation. Module Federation is a completely different concept from single-spa, and allows a JavaScript application to dynamically load code from another application. It completely solves the problem of code dependency sharing and runtime modularity. The idea is true - A game-changer in JavaScript architecture as mentioned in Zack Jackson's article. And it's currently supported by Webpack, Next.js, and Rollup.

Although the Module Federation concept is so amazing, it has not yet gone further to provide a more complete and fully targeted micro frontends framework implementation, and this is what Fronts is trying to do.

Features

  • Non-module-federation - Although Fronts is based on the concept of module federation, it also supports non-module-federation mode.
  • Decentralized configuration - Configure site.json for dependency management in each Fronts app, support for nested micro frontends.
  • Cross frameworks - No framework or technology stack is restricted.
  • Code splitting & lazy loading - Support code splitting within the Fronts app as a module, it can be lazy loaded by other Fronts app as a dependent module.
  • CSS isolation - Optional CSS isolation solution.
  • Lifecycle - Fronts provide concise lifecycle for Fronts app entry.
  • Web Components & iFrame - Support for multiple frontend containers.
  • Multiple patterns - Support for building micro-frontends app and non-micro-frontends app.
  • Monorepo & TypeScript - Friendly support for Monorepo and TypeScript, which are mutually appropriate technology stack.
  • Version control - It's used for efficient and dynamic delivery apps such as canary release.
  • Zero hijacking - Fronts didn't do any hijacking, maintaining originality and possible loss of performance and security.
  • Generic Communication - Fronts provides concise and generic communication APIs, which supports almost all frontend environments.

Getting Started

You can follow this article(React without create-react-app Webpack 5) to quickly create app1 and app2 React projects.

Assuming you've completed these steps, let's get started with a quick taste of the wonderful micro frontends development of Fronts.

  1. Install fronts-react and fronts-bundler in the projects.
# with NPM
npm install fronts-react fronts-bundler

# or with Yarn
yarn add fronts-react fronts-bundler
  1. Set up site.json and webpack.config.js in the projects

We define app1 as a parent micro frontend and it depends on app2.

app1/site.json:

{
  "name": "app1",
  "exports": [],
  "dependencies": {
    "app2": "http://localhost:3002/remoteEntry.js"
  }
}

app2 doesn't have any dependencies, it acts as a micro frontend and we define it to export ./src/bootstrap as a micro frontends entry, this entry of app2 end will be used by app1.

app2/site.json:

{
  "name": "app2",
  "exports": ["./src/bootstrap"],
  "dependencies": {}
}

Wrap the Webpack config with createWebpackConfig() in config/webpack.config.js in the projects.

const { createWebpackConfig } = require('fronts-bundler');

module.exports = createWebpackConfig(originalWebpackConfig);
  1. Define the default exported bootstrap function in app2/src/bootstrap.jsx and use boot() to get it booted.
import React from 'react';
import ReactDOM from 'react-dom';
import { boot } from 'fronts-react';
import App from './App';

export default function render(element) {
  ReactDOM.render(<App />, element);
  return () => {
    ReactDOM.unmountComponentAtNode(element);
  };
}

boot(render, document.getElementById('root'));
  1. Load app1/src/App.jsx with useApp() to import app2.
import React from 'react';
import { useApp } from 'fronts-react';

export const App = () => {
  const App2 = useApp({
    name: 'app2',
    loader: () => import('app2/src/bootstrap'),
  });
  return <App2 />;
};

Examples

APIs

API Isolation
useApp() CSS(loose/optional)
useWebComponents() CSS
useIframe() CSS, JavaScript

Built-in packages

The most popular frontend frameworks are React, Vue and Angular. When the micro frontends uses one of these frameworks, it is recommended to use Fronts built-in package for this framework, such as fronts-react, fronts-vue and fronts-ng, otherwise please use fronts.

Packages Support Framework Status
fronts Any Framework Completed
fronts-react React Completed
fronts-vue Vue In Progress 💡
fronts-ng Angular -

Running Type

Type Requirement Support
Non-Module-Federation - Dependency Management
Monorepo
Version Management
Module Federation Webpack
site.json
Dependency Management
Monorepo
Version Management
Version Control Webpack
site.json
Registry Server
Dependency Management
Monorepo
Version Management

Debugger/Logger

Use getMeta(), it helps you to get the dependency mapping information.

import { getMeta } from 'fronts';

console.log(getMeta());

// {
//   "name": "app3",
//   "meta": {
//       "__main__": "app1",
//       "__entry__": "http://localhost:3001/#/app2",
//       "app2": {
//           "dependencies": {
//               "app3": "http://localhost:3003"
//           }
//       },
//       "app5": {
//           "dependencies": {
//               "app6": "http://localhost:3006"
//           }
//       },
//       "app3": {
//           "dependencies": {}
//       },
//       "app6": {
//           "dependencies": {}
//       },
//       "app1": {
//           "dependencies": {
//               "app2": "http://localhost:3002",
//               "app4": "http://localhost:3004",
//               "app5": "http://localhost:3005"
//           }
//       }
//   }
// }

Testing

fronts-test provides an runner for function step, and any micro frontends IT and E2E can use it for reusable testing. It also provides other APIs, such as useContext(), beforeHook and afterHook in createRunner().

import { $, useContext, Given, When, Then } from 'fronts-test';

const addTodo = $(() => {
  const { page } = useContext();
  await page.type('.text', 'Use Fronts');
  await page.click('.add');
});

test('base', async () => {
  await Given('user open the page').then(entry);
  await When('user add todo text').then(addTodo);
  await Then('user should see that todo list has a new item').then(checkTodo);
});

CLI

todo

Version Control

Set up the registry server URL in the registry field.

It supports dynamic import(), and it does not support static import.

{
  "name": "app1",
  "exports": [],
+ "registry": "http://localhost:3000/dev.json",
  "dependencies": {
-    "app2": "http://localhost:3002/remoteEntry.js"
+    "app2": "1.0.0"
  }
}

Start the registry server and make sure that http://localhost:3000/dev.json?scope=app2%401.0.0 request gets a response data with the version specification.

{
  "app2": "http://localhost:3002/remoteEntry.js"
}

Tutorial

todo

Q&A

Q: Can Non-Module-Federation, Module Federation, and Version Control be compatible with each other?

A: Yes

Q: How to use SPA development mode in micro frontends codebase?

A: Use SPA=true yarn start instead of yarn start, make sure the current codebase is Monorepo and module federation or version control is enabled, and it just works with useApp() and useWebComponent().

License

Fronts is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].