用途:修复 UI5 linter 检测到但无法自动修复的 Component.js 异步配置问题,适用于 linter 报出 async-component-flags 或 no-removed-manifest-property 规则时。在完整现代化流程中,即使未报错也建议对每个 Component.js 主动应用。
主要能力:为组件添加 sap.ui.core.IAsyncContentCreation 接口;补充 manifest: "json" 声明;移除 manifest.json 或内联 manifest 中 rootView、routing/config 的冗余 async 标志;移除 async: false;处理内联 manifest 场景。
关键用法:IAsyncContentCreation 是标记接口,只能以字符串形式写入 metadata 内的 interfaces 数组,绝不能加入 sap.ui.define 依赖数组或作为函数参数,否则运行时报错。interfaces 必须嵌套在 metadata 对象内,与 manifest 同级,而非与 metadata 同级。若已存在该依赖需删除。
实施步骤:读取 Component.js,判断语法风格;检查并添加接口与 manifest 声明;检查 manifest.json 或内联 manifest 并移除冗余 async;写入文件;运行 node <skill-dir>/scripts/verify-component.js <project-root> 验证,须退出码为 0。
限制与注意:该接口自 UI5 1.89 引入,需确认 minUI5Version 兼容;继承自已实现该接口的自定义基类时无需修改;IAsyncContentCreation 与 manifest v2 相互独立,升级 _version 不会自动启用异步,反之亦然。相关技能包括 fix-manifest-json 与 fix-js-globals。