mf-shared-deps
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/shared-config-check.js --context '<MFContext-JSON>'Process each item in the output array:
resultsSHARED-EXTERNALS-CONFLICT · warning — same library in both and
sharedexternals- and
sharedare not mutually exclusive in config, but the same library must not appear in both — it causes the module to be excluded from the bundle while also being declared as shared, leading to runtime failuresexternals - Show the conflicting library name and guide the user to remove it from one of the two configs
SHARED-TRANSFORM-IMPORT · warning — antd/arco UI library shared but is active
transformImport- (or the built-in
babel-plugin-importin Modern.js / Rsbuild) rewrites import paths at build time, which prevents the shared dep from being recognized and causes sharing to fail silentlytransformImport - Fix:
- Modern.js / Rsbuild: set to disable the built-in behavior
source.transformImport = false - Other bundlers: remove from the Babel config
babel-plugin-import
- Modern.js / Rsbuild: set
- Show which UI library triggered the warning
SHARED-MULTI-VERSION · warning — multiple versions of the same shared package detected
- The build artifacts contain more than one version of a shared package, meaning the version negotiation failed and both host and remote are each bundling their own copy
- Recommended fix: add an in the bundler config so all projects resolve to the same physical file
alias - Show the detected versions
When results is empty
- Inform the user that no shared dependency conflicts were detected in this project
- Remind them that a complete picture requires running the same check in both the host and every remote
步骤1:调用 Skill(传入)来收集MFContext。
mf-context$ARGUMENTS步骤2:将MFContext序列化为JSON,通过参数传递给检查脚本:
--contextbash
node scripts/shared-config-check.js --context '<MFContext-JSON>'处理输出数组中的每个项:
resultsSHARED-EXTERNALS-CONFLICT · 警告 — 同一库同时出现在和中
sharedexternals- 和
shared在配置中并非互斥,但同一库不能同时出现在两者中——这会导致模块被排除在打包文件之外,同时又被声明为共享,进而引发运行时错误externals - 显示冲突的库名称,并引导用户从其中一个配置中移除该库
SHARED-TRANSFORM-IMPORT · 警告 — antd/arco UI库已设置共享,但处于激活状态
transformImport- (或Modern.js / Rsbuild中的内置
babel-plugin-import)会在构建时重写导入路径,这会导致共享依赖无法被识别,进而使共享功能静默失效transformImport - 修复方案:
- Modern.js / Rsbuild:设置以禁用内置行为
source.transformImport = false - 其他打包工具:从Babel配置中移除
babel-plugin-import
- Modern.js / Rsbuild:设置
- 显示触发警告的UI库名称
SHARED-MULTI-VERSION · 警告 — 检测到同一共享包存在多个版本
- 构建产物中包含同一共享包的多个版本,这意味着版本协商失败,宿主和远程应用各自打包了自己的副本
- 推荐修复方案:在打包工具配置中添加,使所有项目解析到同一个物理文件
alias - 显示检测到的版本
当results为空时
- 告知用户当前项目中未检测到共享依赖冲突
- 提醒用户,若要获取完整的检查结果,需要在宿主应用和所有远程应用中都运行相同的检查