@appshell/config

中文文档
1.0.0-alpha.148发布于 2026/10/30MITTypeScriptCommonJS构建来源已验证近 30 天下载 5601

Utility for producing a global appshell manifest for module federation micro-frontends

原始使用文档
文档目录3 节
  1. Getting Started
  2. Functions
  3. generateManifest

Appshell CI

@appshell/config

Utitliy to generate appshell configuration for building micro-frontends with Appshell and Webpack Module federation.

Working examples can be found here.

Note: This package is no longer published, and it's recommended to use the @appshell/cli instead.

Getting Started

To begin, you'll need to install @appshell/config:

npm install @appshell/config --save-dev

or

yarn add -D @appshell/config

or

pnpm add -D @appshell/config

Functions

@appshell/config is the library the CLI is built on. Most of it is reachable through appshell commands; reach for the package directly when you are scripting a build.

ExportPurposeCLI equivalent
generateManifestTemplate → manifest, expanding ${VAR}appshell generate manifest
publishPublish a manifest as a package versionappshell publish
activateActivate a version into an applicationappshell publish --application
outdatedCompare shared dependencies against baselinesappshell outdated
syncInstall shared dependencies at the declared versions—
resolveContext / persistedContextRegistry, application and token, resolved as the CLI resolves themappshell config list
resolveToken / saveCredential / clearCredential / credentialsPathStored credentials, per registryappshell login / logout
configmap${VAR} placeholder expansion—
utilsFile loading, comparison and formatting helpers—
validatorsAppshellTemplateValidator—

generateManifest

Processes one manifest template into an appshell manifest, expanding ${VAR} placeholders from the current environment.

import { generateManifest } from '@appshell/config';

const manifest = await generateManifest<MyMetadata>('dist/appshell.template.json');

Where does the template come from?

Each micro-frontend configured with @appshell/webpack-plugin emits appshell.template.json at build time. This function turns that into the manifest a package version is published with.

Sample template:

{
  "remotes": {
    "CraModule/App": {
      "url": "${CRA_MFE_URL}",
      "metadata": {
        "route": "/cra",
        "displayName": "Example App",
        "displayGroup": "${CRA_MFE_DISPLAY_GROUP}",
        "order": 10,
        "icon": "ViewList"
      },
      "id": "3eb81a0c"
    }
  },
  "module": {
    "exposes": {
      "./App": "./src/App"
    },
    "filename": "remoteEntry.js",
    "name": "CraModule",
    "shared": {
      "react": {
        "singleton": true,
        "requiredVersion": "^18.2.0"
      },
      "react-dom": {
        "singleton": true,
        "requiredVersion": "^18.2.0"
      }
    }
  },
  "vars": {
    "RUNTIME_ARG_1": "${RUNTIME_ARG_1}",
    "RUNTIME_ARG_2": "${RUNTIME_ARG_2}"
  }
}

How does my runtime environment get reflected in the global appshell manifest?

Note the variable expansion syntax ${CRA_MFE_URL}. When generateManifest is called the actual runtime environment values are injected and an appshell manifest is emitted.

Note the vars section defines runtime configuration values a package reads with getVars() from @appshell/runtime/vars once it is loaded. The package must share @appshell/runtime as a singleton to receive them. See the examples for a use case.

Sample appshell manifest produced by the generateManifest function:

{
  "remotes": {
    "CraModule/App": {
      "id": "3eb81a0c",
      "url": "http://localhost:3001/remoteEntry.js",
      "scope": "CraModule",
      "module": "./App",
      "metadata": {
        "route": "/cra",
        "displayName": "Example App",
        "displayGroup": "primary",
        "order": 10,
        "icon": "ViewList"
      }
    },
    "VanillaModule/Vanilla": {
      "id": "8232ce86",
      "url": "http://localhost:3002/remoteEntry.js",
      "scope": "VanillaModule",
      "module": "./Vanilla",
      "metadata": {
        "route": "/vanilla",
        "displayName": "Example React App",
        "displayGroup": "primary",
        "order": 10,
        "icon": "ViewList"
      }
    }
  },
  "modules": {
    "Appshell": {
      "name": "Appshell",
      "shared": {
        "react": {
          "singleton": true,
          "requiredVersion": "^18.2.0"
        },
        "react-dom": {
          "singleton": true,
          "requiredVersion": "^18.2.0"
        }
      }
    },
    "CraModule": {
      "exposes": {
        "./App": "./src/App"
      },
      "filename": "remoteEntry.js",
      "name": "CraModule",
      "shared": {
        "react": {
          "singleton": true,
          "requiredVersion": "^18.2.0"
        },
        "react-dom": {
          "singleton": true,
          "requiredVersion": "^18.2.0"
        }
      }
    },
    "VanillaModule": {
      "exposes": {
        "./Vanilla": "./src/App"
      },
      "filename": "remoteEntry.js",
      "name": "VanillaModule",
      "shared": {
        "react": {
          "singleton": true,
          "requiredVersion": "^18.2.0"
        },
        "react-dom": {
          "singleton": true,
          "requiredVersion": "^18.2.0"
        }
      }
    }
  },
  "vars": {
    "CraModule": {
      "RUNTIME_ARG_1": "Foo",
      "RUNTIME_ARG_2": "Biz"
    },
    "VanillaModule": {
      "RUNTIME_ARG_1": "Bar"
    }
  }
}

This manifest is what publish sends to the registry as a package version. The registry composes every activated package into the payload it serves to the shell.

What if I want to generate the manifest by a startup script instead?

This functionality is exposed by the @appshell/cli package. You can simply call appshell generate manifest --template /path/to/appshell.template.json to produce the runtime manifest on startup.

版本与发布记录

@appshell/config 共发布 218 个版本,首次发布于 2023/03/04;过去 12 个月发布了 141 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0-alpha.148latest2026/10/309 天前
1.0.0-alpha.1472026/10/2910 天前
1.0.0-alpha.1462026/10/2810 天前
1.0.0-alpha.1452026/10/2810 天前
1.0.0-alpha.1442026/10/2712 天前
1.0.0-alpha.1432026/10/2613 天前

关于 @appshell/config 的常见问题

@appshell/config 是什么?

Utility for producing a global appshell manifest for module federation micro-frontends

如何安装 @appshell/config?

在项目目录运行 npm install @appshell/config,或使用 pnpm add / yarn add / bun add。

@appshell/config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@appshell/config 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@appshell/config 可以商用吗?

@appshell/config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@appshell/config 的下载量有多少?

根据 npm 官方下载统计,@appshell/config 在 2026/10/07 – 2026/11/05 这 30 天内被下载 5,601 次,日均约 187 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appshell/config 还在维护吗?

最新版本 1.0.0-alpha.148 发布于 2026/10/30(9 天前);至今共发布 218 个版本,其中过去 12 个月发布了 141 个;首次发布于 2023/03/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。