mf-perf
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStep 1: Call the Skill (pass ) to collect MFContext.
mf-context$ARGUMENTSStep 2: Serialize MFContext to JSON and pass it to the check script via the argument:
--contextbash
node scripts/performance-check.js --context '<MFContext-JSON>'Provide recommendations for each item in the output and :
resultscontext.bundler.namePERF · info — (applies to all projects)
dev.disableAssetsAnalyze- Disabling bundle size analysis during local development significantly improves HMR speed
- Add to the Rsbuild config:
js
dev: { disableAssetsAnalyze: true }
PERF · info — Rspack optimization (shown only when is or )
splitChunksbundler.namerspackrsbuild- Setting to
splitChunks.chunksreduces initial bundle size and speeds up first-screen loading"async" - Add to the build config:
js
output: { splitChunks: { chunks: 'async' } }
PERF · info — TypeScript DTS optimization (shown only when dependency is detected)
typescript- If type generation (DTS) is the main bottleneck, options include:
- Temporarily disable DTS: set in the
dts: falseconfig@module-federation/enhanced - Switch to for significantly faster type generation
ts-go
- Temporarily disable DTS: set
Step 3: After presenting the DTS recommendation, ask the user:
"Would you like me to automatically try switching toand verify compatibility?"ts-go
If the user confirms, execute the following steps in order:
-
Backup — copy the current generated type output directory (e.g.) to a timestamped backup path such as
@mf-types/@mf-types.bak.<timestamp>/ -
Configure — setin the Module Federation config
dts.generateTypes.compilerInstance = "tsgo" -
Install — install the required package:bash
npm install @typescript/native-preview --save-dev(use the project's actual package manager from MFContext) -
Regenerate — run:bash
npx mf dts -
Verify — diff the newly generated type output against the backup:
- If the output is identical: inform the user that is compatible and the switch is safe; offer to remove the backup
ts-go - If the output differs: revert the config change, restore the backup, and explain clearly what differs (e.g. missing declarations, changed signatures) so the user can decide whether the difference is acceptable
- If the output is identical: inform the user that
Webpack projects do not show Rspack-specific entries to avoid irrelevant suggestions.
步骤1:调用 Skill(传入)来收集MFContext。
mf-context$ARGUMENTS步骤2:将MFContext序列化为JSON,通过参数传递给检查脚本:
--contextbash
node scripts/performance-check.js --context '<MFContext-JSON>'针对输出的和中的每个项提供建议:
resultscontext.bundler.namePERF · 信息 — (适用于所有项目)
dev.disableAssetsAnalyze- 在本地开发期间禁用包大小分析可显著提升HMR速度
- 添加到Rsbuild配置中:
js
dev: { disableAssetsAnalyze: true }
PERF · 信息 — Rspack 优化(仅当为或时显示)
splitChunksbundler.namerspackrsbuild- 将设置为
splitChunks.chunks可减小初始包大小并加快首屏加载速度"async" - 添加到构建配置中:
js
output: { splitChunks: { chunks: 'async' } }
PERF · 信息 — TypeScript DTS优化(仅当检测到依赖时显示)
typescript- 如果类型生成(DTS)是主要瓶颈,可选方案包括:
- 临时禁用DTS:在配置中设置
@module-federation/enhanceddts: false - 切换到以大幅提升类型生成速度
ts-go
- 临时禁用DTS:在
步骤3:在展示DTS建议后,询问用户:
"是否需要我自动尝试切换到并验证兼容性?"ts-go
如果用户确认,按以下顺序执行步骤:
-
备份 — 将当前生成的类型输出目录(例如)复制到带时间戳的备份路径,如
@mf-types/@mf-types.bak.<timestamp>/ -
配置 — 在Module Federation配置中设置
dts.generateTypes.compilerInstance = "tsgo" -
安装 — 安装所需包:bash
npm install @typescript/native-preview --save-dev(使用MFContext中项目实际的包管理器) -
重新生成 — 运行:bash
npx mf dts -
验证 — 将新生成的类型输出与备份进行对比:
- 如果输出完全一致:告知用户兼容,切换是安全的;可选择移除备份
ts-go - 如果输出存在差异:还原配置更改,恢复备份,并清晰说明差异点(例如缺少声明、签名变更),以便用户决定差异是否可接受
- 如果输出完全一致:告知用户
Webpack项目不会显示Rspack相关条目,以避免无关建议。