All Projects → ice-lab → Icestark

ice-lab / Icestark

Licence: mit
🐯 Micro Frontends solution for large application(面向大型应用的微前端解决方案)

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Icestark

Redux Bundler
Compose a Redux store out of smaller bundles of functionality.
Stars: ✭ 579 (-46.04%)
Mutual labels:  frontend, spa
Captain Fact Frontend
🔎 CaptainFact - Frontend. The one you see on https://captainfact.io
Stars: ✭ 74 (-93.1%)
Mutual labels:  frontend, spa
Laravel Vuetify Spa
Laravel-Vue SPA starter project template with Vuetify frontend.
Stars: ✭ 73 (-93.2%)
Mutual labels:  frontend, spa
Koa Vue Notes Web
🤓 This is a simple SPA built using Koa as the backend, Vue as the first frontend, and React as the second frontend. Features MySQL integration, user authentication, CRUD note actions, and Vuex store modules.
Stars: ✭ 200 (-81.36%)
Mutual labels:  frontend, spa
Prism
Build frontend web apps with Ruby and WebAssembly
Stars: ✭ 251 (-76.61%)
Mutual labels:  frontend, spa
Webhook.site
⚓️ Easily test HTTP webhooks with this handy tool that displays requests instantly.
Stars: ✭ 2,842 (+164.86%)
Mutual labels:  frontend, spa
Nuxt Chat App
Frontend of real-time chat application built using nuxtjs, socket.io. Check the backend at https://github.com/binbytes/chat-app-server.
Stars: ✭ 77 (-92.82%)
Mutual labels:  frontend, spa
Vuefront
VueFront Core. Turn your old-fashioned CMS website in to a SPA & PWA in 5 minutes
Stars: ✭ 316 (-70.55%)
Mutual labels:  frontend, spa
Aurelia
Aurelia 2, a standards-based, front-end framework designed for high-performing, ambitious applications.
Stars: ✭ 995 (-7.27%)
Mutual labels:  frontend, spa
Fireblog
Blog template in elm for easy deploy on Firebase!
Stars: ✭ 44 (-95.9%)
Mutual labels:  spa
Company Structure
A company structure with a list of projects and their users
Stars: ✭ 48 (-95.53%)
Mutual labels:  frontend
Nico
A HTTP2 web server for reverse proxy and single page application, automatically apply for ssl certificate, Zero-Configuration.
Stars: ✭ 43 (-95.99%)
Mutual labels:  spa
Omg Counters
😍 Increment decrement counters using various frontend frameworks.
Stars: ✭ 44 (-95.9%)
Mutual labels:  frontend
F2e
🔥 大前端进阶知识扫盲,前端同学必看,后端同学也能看懂,看不懂你加我微信骂我渣男就好了!(欢迎star,持续更新)
Stars: ✭ 1,045 (-2.61%)
Mutual labels:  frontend
Elm Hn Pwa
Hacker News as a PWA built with Elm
Stars: ✭ 43 (-95.99%)
Mutual labels:  spa
Serverless Application
🍤 ALIS Media - Serverless Application
Stars: ✭ 52 (-95.15%)
Mutual labels:  spa
Vanilla Ui Router
Simple vanilla JavaScript router
Stars: ✭ 42 (-96.09%)
Mutual labels:  spa
Webrix
Powerful building blocks for React-based web applications
Stars: ✭ 41 (-96.18%)
Mutual labels:  frontend
Svelte Store Router
Store-based router for Svelte
Stars: ✭ 54 (-94.97%)
Mutual labels:  frontend
Opencart
Free PWA & SPA for OpenCart
Stars: ✭ 50 (-95.34%)
Mutual labels:  spa

English | 简体中文

icestark

Micro Frontends solution for large application. Website Chinese docs.

NPM version Package Quality build status Test coverage NPM downloads David deps

Features 🎉

  • No framework constraint for main&sub applications, support React/Vue/Angular/...
  • Sub-application support multiple types of entry: js&css, html entry, html content
  • Compatible with single-spa sub-application and lifecycles
  • JavaScript sandbox by Proxy API

Showcases 🎃

Vue main-application

https://icestark-vue.surge.sh/

Main-application based on Vue, And sub-applications based on React, Vue respectively.

React main-application

https://icestark-react.surge.sh/

Main-application based on React, And sub-applications based on React, Vue, Angular respectively.

Architecture&Concepts 🚁

Concepts:

  • Main-application: also named framework application, responsible for sub-applications registration&load&render, layout display (Header, Sidebar, Footer, etc.)
  • Sub-application: responsible for content display related to its own business

Getting Started 🥢🍚

Use Scaffold

Main-application:

# Based on React
$ npm init ice icestark-layout @icedesign/stark-layout-scaffold
# Based on Vue
$ npm init ice icestark-layout @vue-materials/icestark-layout-app

$ cd icestark-layout
$ npm install
$ npm start

Sub-application:

# Based on React
$ npm init ice icestark-child @icedesign/stark-child-scaffold
# Based on Vue
$ npm init ice icestark-child @vue-materials/icestark-child-app

$ cd icestark-child
$ npm install
$ npm run start

Main-application

setup in react app

// src/App.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import { AppRouter, AppRoute } from '@ice/stark';

class App extends React.Component {
  onRouteChange = (pathname, query) => {
    console.log(pathname, query);
  };

  render() {
    return (
      <div>
        <div>this is common header</div>
        <AppRouter
          onRouteChange={this.onRouteChange}
          ErrorComponent={<div>js bundle loaded error</div>}
          NotFoundComponent={<div>NotFound</div>}
        >
          <AppRoute
            path={['/', '/message', '/about']}
            exact
            title="通用页面"
            url={['//unpkg.com/icestark-child-common/build/js/index.js']}
          />
          <AppRoute
            path="/seller"
            url={[
              '//unpkg.com/icestark-child-seller/build/js/index.js',
              '//unpkg.com/icestark-child-seller/build/css/index.css',
            ]}
          />
        </AppRouter>
        <div>this is common footer</div>
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('ice-container'));
  • AppRouter locates the sub-application rendering node
  • AppRoute corresponds to the configuration of a sub-application, path configures all route information, basename configures a uniform route prefix, url configures assets url
  • icestark will follow the route parsing rules like to determine the current path, load the static resources of the corresponding sub-application, and render

setup with APIs

supported by @ice/[email protected]

import { registerMicroApps } from '@ice/stark';

regsiterMicroApps([
  {
    name: 'app1',
    activePath: ['/', '/message', '/about'],
    exact: true,
    title: '通用页面',
    container: document.getElementById('icestarkNode'),
    url: ['//unpkg.com/icestark-child-common/build/js/index.js'],
  },
  {
    name: 'app2',
    activePath: '/seller',
    title: '商家平台',
    container: document.getElementById('icestarkNode'),
    url: [
      '//unpkg.com/icestark-child-seller/build/js/index.js',
      '//unpkg.com/icestark-child-seller/build/css/index.css',
    ],
  },
]);

start();

after sub-application is registered, icestark will load app according to the activePath.

Sub-application

sub-application can expose lifecycles in both register lifecycles and export lifecycles(umd) ways.

1. regsiter lifecycles

// src/index.js
import ReactDOM from 'react-dom';
import { isInIcestark, getMountNode, registerAppEnter, registerAppLeave } from '@ice/stark-app';
import router from './router';

if (isInIcestark()) {
  const mountNode = getMountNode();

  registerAppEnter(() => {
    ReactDOM.render(router(), mountNode);
  });

  // make sure the unmount event is triggered
  registerAppLeave(() => {
    ReactDOM.unmountComponentAtNode(mountNode);
  });
} else {
  ReactDOM.render(router(), document.getElementById('ice-container'));
}
  • Get the render DOM Node via getMountNode
  • Trigger app mount manually via registerAppEnter
  • Trigger app unmount manually via registerAppLeave
// src/router.js
import React from 'react';
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { renderNotFound, getBasename } from '@ice/stark-app';

function List() {
  return <div>List</div>;
}

function Detail() {
  return <div>Detail</div>;
}

export default class App extends React.Component {
  render() {
    return (
      <Router basename={getBasename()}>
        <Switch>
          <Route path="/list" component={List} />
          <Route path="/detail" component={Detail} />
          <Redirect exact from="/" to="list" />
          <Route
            component={() => {
              return renderNotFound();
            }}
          />
        </Switch>
      </Router>
    );
  }
}
  • Get the basename configuration in the framework application via getBasename
  • renderNotFound triggers the framework application rendering global NotFound

2. exports lifecycles(umd)

exports lifecycles in sub-application:

import ReactDOM from 'react-dom';
import App from './app';

export function mount(props) {
  ReactDOM.render(<App />, document.getElementById('icestarkNode'));
}

export function unmount() {
  ReactDOM.unmountComponentAtNode(document.getElementById('icestarkNode'));
}

sub-application should be bundled as an UMD module, add the following configuration of webpack:

module.exports = {
  output: {
    library: 'sub-app-name',
    libraryTarget: 'umd',
  },
};

Documentation 📝

https://ice.work/docs/icestark/about

Ecosystem 🧼

Project Version Docs Description
icejs icejs-status docs A universal framework based on react.js
icestore icestore-status docs Simple and friendly state for React
formily formily-status docs Alibaba Group Unified Form Solution
iceworks iceworks-status docs Universal Application Development Pack for VS Code

Contributors

Feel free to report any questions as an issue, we'd love to have your helping hand on icestark.

If you're interested in icestark, see CONTRIBUTING.md for more information to learn how to get started.

License

MIT

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