datahub-mfe-create-app
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate a DataHub MFE App
创建DataHub MFE应用
Scaffolds a complete, working Micro Frontend app that integrates with DataHub
via Webpack Module Federation. Generates all 7 required files and guides the
user through building and verifying.
生成一个可直接运行、完整的微前端应用,该应用通过Webpack Module Federation与DataHub集成。生成全部7个所需文件,并引导用户完成构建与验证流程。
Step 1: Gather Information
步骤1:收集信息
Use the AskQuestion tool to collect the following in a single call.
| Question | ID | Options |
|---|---|---|
App name (kebab-case, e.g. | | |
| Brief description of what the app does | | |
| Dev server port | | |
| Does the app need to call the DataHub GraphQL API? | | |
For and , present only the
option — do NOT suggest values from the workspace. The user will type their own.
app_nameapp_descN/A - I'll fill it in later使用AskQuestion工具一次性收集以下信息。
| 问题 | ID | 选项 |
|---|---|---|
应用名称(短横线命名法,例如 | | |
| 应用功能简要描述 | | |
| 开发服务器端口 | | |
| 应用是否需要调用DataHub GraphQL API? | | |
对于和,仅提供选项——请勿从工作区中建议取值,用户将自行输入。
app_nameapp_descN/A - 我稍后填写Deriving names from app_name
app_name从app_name
衍生名称
app_nameGiven an like :
app_nameteam-dashboard- Directory: (append
team-dashboard-mfe/if not already present)-mfe - Module Federation name (): convert to camelCase and append
MF_NAME—MFEteamDashboardMFE - Package name: same as directory name, e.g.
team-dashboard-mfe - Display label: title-case the words, e.g.
Team Dashboard
假设为:
app_nameteam-dashboard- 目录:(如果末尾没有
team-dashboard-mfe/则添加)-mfe - Module Federation名称():转换为驼峰命名并追加
MF_NAME——MFEteamDashboardMFE - 包名称:与目录名称相同,例如
team-dashboard-mfe - 显示标签:每个单词首字母大写,例如
Team Dashboard
Step 2: Generate Files
步骤2:生成文件
Create the directory at the workspace root (sibling to ).
Generate all 7 files using the templates in templates.md.
datahub-web-react/Apply these substitutions to every template:
| Placeholder | Value |
|---|---|
| Directory name |
| Package name |
| User's description |
| Dev server port |
| Module Federation name (camelCase + MFE) |
| Title-cased label |
| |
If is Yes, include the GraphQL proxy block in
(marked with in the template). If No, omit it entirely.
needs_graphqlwebpack.config.js{{GRAPHQL_PROXY}}在工作区根目录(与同级)创建目录。使用templates.md中的模板生成全部7个文件。
datahub-web-react/对所有模板进行以下替换:
| 占位符 | 取值 |
|---|---|
| 目录名称 |
| 包名称 |
| 用户提供的描述 |
| 开发服务器端口 |
| Module Federation名称(驼峰命名 + MFE) |
| 首字母大写的标签 |
| |
如果为是,则在中包含GraphQL代理块(模板中标记为)。如果为否,则完全省略该块。
needs_graphqlwebpack.config.js{{GRAPHQL_PROXY}}Files to generate
需生成的文件
package.jsonwebpack.config.jssrc/mount.tsxsrc/index.tsxsrc/App.tsxtsconfig.jsonpublic/index.html
package.jsonwebpack.config.jssrc/mount.tsxsrc/index.tsxsrc/App.tsxtsconfig.jsonpublic/index.html
Step 3: Install and Start
步骤3:安装与启动
First into the app directory — webpack must be started from within it,
not from the workspace root.
cdbash
cd __APP_DIR__
npm install
npm startWait for webpack to compile. The dev server should start on the configured port.
首先进入应用目录——webpack必须从目录内部启动,而非工作区根目录。
bash
cd __APP_DIR__
npm install
npm start等待webpack编译完成。开发服务器应在配置的端口启动。
Step 4: Verify
步骤4:验证
- Open in a browser or curl it. It should return JavaScript (not a 404 or HTML error page).
http://localhost:<PORT>/remoteEntry.js - Open — the standalone dev page should render.
http://localhost:<PORT>/
If either check fails, review the webpack output for errors and fix before
proceeding.
- 在浏览器中打开或使用curl访问。应返回JavaScript代码(而非404或HTML错误页面)。
http://localhost:<PORT>/remoteEntry.js - 打开——独立开发页面应正常渲染。
http://localhost:<PORT>/
如果任一检查失败,请查看webpack输出中的错误并修复后再继续。
Step 5: Next Steps
步骤5:后续操作
Tell the user:
Your MFE app is running! To integrate it with DataHub, use the datahub-mfe-configure-app skill — it will walk you through adding this app to the DataHub frontend config so it appears atand optionally in the nav sidebar./mfe/<path>
Provide a summary of what was created:
Created __APP_DIR__/ with 7 files:
package.json — dependencies and scripts
webpack.config.js — Module Federation + dev server
src/mount.tsx — mount() contract for DataHub
src/index.tsx — standalone dev entry point
src/App.tsx — starter React component
tsconfig.json — TypeScript config
public/index.html — dev HTML shell
Module Federation name: __MF_NAME__ ← use this as "MFE app name" in datahub-mfe-configure-app
Remote entry URL: http://localhost:__PORT__/remoteEntry.js
Module path: __MF_NAME__/mount告知用户:
你的MFE应用已运行!要将其与DataHub集成,请使用datahub-mfe-configure-app技能——它将引导你将此应用添加到DataHub前端配置中,使其在路径下显示,并可选择添加到导航侧边栏。/mfe/<path>
提供已创建内容的摘要:
已创建 __APP_DIR__/ 目录及7个文件:
package.json — 依赖项与脚本
webpack.config.js — Module Federation + 开发服务器配置
src/mount.tsx — 供DataHub调用的mount()契约
src/index.tsx — 独立开发入口文件
src/App.tsx — 初始React组件
tsconfig.json — TypeScript配置
public/index.html — 开发用HTML外壳
Module Federation名称: __MF_NAME__ ← 在datahub-mfe-configure-app中用作“MFE应用名称”
远程入口URL: http://localhost:__PORT__/remoteEntry.js
模块路径: __MF_NAME__/mount