npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@runnan/open-platform-demo

v1.0.0

Published

My webpack project

Downloads

3

Readme

Rallie Open Platform

介绍

这是一个用来验证基于rallieJS搭建微内核架构的前端应用的可行性的项目

微内核架构的好处:

  • 解耦巨石应用
  • 支持外部插件扩展

技术栈

  • 组件库:Antd
  • 应用骨架:Antd Pro
  • 插件治理:rallie

插件接入

宿主应用的Block声明参考src/typings/index.ts#CoreType

样例插件参考:ralliejs/demo-plugin

注入runtime

将core注入的runtime配置为external

import { defineConfig } from 'vite'
import { viteExternalsPlugin } from "vite-plugin-externals";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  base: "",
  plugins: [
    react({
      jsxRuntime: "classic",
    }),
    viteExternalsPlugin(
      {
        react: "React",
        "react-dom": "ReactDOM",
        "react-router-dom": "ReactRouterDOM",
        antd: "Antd",
      },
      {
        filter: () => true,
      }
    ),
  ],
});

webpack可自行配置

创建插件block

import { createBlock } from '@rallie/block'

const myPlugin = createBlock('{github用户名}/{github仓库名}')
  .relyOn(['core'])
  .onActivate(() => {
    const core = myPlugin.connect('core')
    // 这里注册扩展逻辑
  })

myPlugin.run(async (env) => {
  if (env.isEntry) { // 插件在本地开发时也能看到整个应用全貌
    const { loadHtml } = await import("@rallie/load-html");
    env.use(
      loadHtml({
        entries: {
          core: "https://ralliejs.github.io/open-platform/#core",
        },
      })
    );
    myPlugin.activate(myPlugin.name);
  }
});

注册扩展逻辑

  • 添加多语言
const core = myPlugin.connect('core')
core.methods.addI18nResources({
  'zh-CN': () => import('path/to/your/zh-CN/resource'),
  'en-US': () => import('path/to/your/en-US/resource')
})
  • 使用多语言
const core = myPlugin.connect('core')
// useTranslation是react-i18next的useTranslation,不用关心namespace,开放平台会为插件注册的多语言资源注册唯一的namespace
const { useTranslation } = core.methods
  • 替换首页
const core = myPlugin.connect('core')
core.methods.replaceSlot('home', () => import('path/to/your/component'))
  • 添加路由
const core = myPlugin.connect('core')
core.methods.addApplication({
  path: 'my-route', // 推荐使用相对路径,如果用绝对路径,必须加上前缀`/app/${插件block名}`
  name: '我的页面'
  locale: 'parent.locale.key'
  loader: () => import('path/to/your/component'),
  icon?: () => import('path/to/your/icon/component')
  children: [
    {
      path: 'child-route',
      name: '子页面',
      locale: 'child.locale.key'
      loader: () => import('path/to/your/child/component'),
    }
  ]
})
// 其他配置项参考react-router-dom和@ant-design/pro-layout
  • 注册插件信息
const core = myPlugin.connect('core')
core.methods.registerPluginInfo({
  title: 'locale.title.key',
  description: 'locale.description.key',
})

部署

将应用部署到Github Page,然后到 https://ralliejs.github.io/open-platform 安装插件即可

参考action

name: Deploy github page

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: pnpm/action-setup@v2
        with:
          version: 7
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'pnpm'
      - name: Install Dependencies
        run: pnpm install
      - name: Build
        run: pnpm build
      - name: Deploy github page
        uses: JamesIves/[email protected]
        with:
          branch: gh-page # The branch the action should deploy to.
          folder: dist # The folder the action should deploy.