🔧fix-component-async
- プラグイン
- ui5-modernization
- ソース
- GitHub で見る ↗
説明
UI5 linterが検出するものの自動修正できない、`Component.js`の非同期設定に関する問題を修正します。 次のような場合に使用: linterが以下のルール違反を出力したとき: - `async-component-flags` — `IAsyncContentCreation`インターフェースの欠落、manifestの宣言漏れ、冗長な非同期フラグ、`async:false`エラーに対応 - `no-removed-manifest-property` — インラインmanifest v2における非同期フラグに対応 非同期ロード・`IAsyncContentCreation`・manifest宣言に関するエラーを含む`Component.js`ファイルで実行してください。 `IAsyncContentCreation`インターフェースの追加と、manifestの適切な設定を自動的に行います。
原文を表示
Fix Component.js async configuration issues that UI5 linter reports but cannot auto-fix. Use this skill when linter outputs these rules: - `async-component-flags` - For missing IAsyncContentCreation interface, missing manifest declaration, redundant async flags, async:false errors - `no-removed-manifest-property` - For async flags in inline manifest v2 Trigger on Component.js files with errors about async loading, IAsyncContentCreation, manifest declaration. Automatically adds the IAsyncContentCreation interface and configures manifest properly.
ユースケース
- ✓async-component-flagsルール違反を修正するとき
- ✓no-removed-manifest-propertyエラーを解決するとき
- ✓IAsyncContentCreationインターフェースを追加するとき
- ✓Component.jsの非同期設定を正規化するとき
本文(日本語訳)
Component.js 非同期設定の修正
このスキルは、UI5 リンターが検出しても自動修正できない Component.js の非同期設定の問題を修正します。自動修正が難しい理由は、コンポーネントのローディング動作への理解が必要なためです。
対象リンタールール
| ルール ID | メッセージパターン | このスキルの対処 |
|---|---|---|
async-component-flags |
Component is not configured for asynchronous loading | IAsyncContentCreation インターフェースを追加 |
async-component-flags |
Component does not specify that it uses the descriptor via the manifest.json file | manifest: "json" を追加 |
async-component-flags |
Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag ... should be removed | manifest から async フラグを削除 |
async-component-flags |
The 'async' property at '...' must be removed | async: false を削除 |
no-removed-manifest-property |
Property '...' has been removed in Manifest Version 2 | async プロパティを削除 |
次のような場合に使用
次のようなリンター出力が確認できる場合に、このスキルを適用してください:
Component.js:5:1 error Component is not configured for asynchronous loading. async-component-flags
Component.js:5:1 warning Component does not specify that it uses the descriptor via the manifest.json file async-component-flags
Component.js:10:5 warning Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag at '/sap.ui5/rootView/async' should be removed async-component-flags
manifest.json:25:9 error The 'async' property at '/sap.ui5/rootView/async' must be removed async-component-flags
完全なモダナイゼーションワークフローにおける重要事項:
リンターが async-component-flags を検出していない場合でも、すべての Component.js に対して無条件にこのスキルを適用してください。
リンターが「インターフェースが存在しない」エラーを検出できるのは、manifest.json から冗長な async: true フラグが削除された後のみです。そのため、モダナイゼーションの初期フェーズではエラーが表示されないことがあります。IAsyncContentCreation は常に予防的に追加してください。
重要ルール
IAsyncContentCreation をインポートしてはならない
IAsyncContentCreation はマーカーインターフェースです。UI5 ランタイムは interfaces 配列内の文字列としてその名前を確認します。
モジュール依存関係としてインポートしてはなりません。sap.ui.define の依存関係配列に追加すると、sap/ui/core/IAsyncContentCreation はロード可能なモジュールではないため、ランタイムエラーが発生します。
// 誤り — インポートしないこと
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/core/IAsyncContentCreation" // ← 誤り: ランタイムエラーになる
], function(UIComponent, IAsyncContentCreation) {
...
});
// 正しい — interfaces 内で文字列として参照するのみ
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json",
interfaces: ["sap.ui.core.IAsyncContentCreation"] // ← 文字列参照のみ
}
});
});
既存の依存関係配列に "sap/ui/core/IAsyncContentCreation" が含まれている場合は、それと対応する関数パラメーターを削除してください。
interfaces の正しい配置場所
interfaces は metadata オブジェクトのプロパティです。必ず metadata: { } の内側にネストする必要があります。
UIComponent.extend() の設定オブジェクトには 2 つの階層があります:
UIComponent.extend("name", {
metadata: { ← レベル 1: コンポーネント設定
manifest: "json", ← レベル 2: metadata プロパティ
interfaces: [...] ← レベル 2: interfaces はここに置く
},
init: function() {} ← レベル 1: コンポーネント設定
});
UI5 ランタイムが interfaces を読み取るのは metadata オブジェクト内のみです。
レベル 1(metadata の兄弟要素)に配置してしまうと、エラーなく無視されてしまい、コンポーネントが非同期として認識されません。
編集後に確認してください: interfaces は metadata: より 1 段深くインデントされていますか?
そうなっていない場合、配置場所が誤っています。
修正方針
1. async-component-flags — IAsyncContentCreation インターフェースの追加
IAsyncContentCreation インターフェースは、コンポーネントが非同期でコンテンツをロードすることを宣言するモダンな方法です。
正しい例 — interfaces を metadata 内にネスト:
// 修正前
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json"
}
});
});
// 修正後
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json",
interfaces: ["sap.ui.core.IAsyncContentCreation"]
}
});
});
誤った例 — interfaces のネストレベルが間違っている:
// 誤り — interfaces が metadata の兄弟要素になっている(レベル 2 ではなくレベル 1)
return UIComponent.extend("my.app.Component", {
interfaces: ["sap.ui.core.IAsyncContentCreation"], // ← 誤り: metadata の外にある
metadata: {
manifest: "json"
}
});
2. async-component-flags — manifest 宣言の追加
コンポーネントが manifest の使用を宣言していない場合、metadata に manifest: "json" を追加します。
// 修正前
metadata: {
// manifest の宣言なし
}
// 修正後
metadata: {
manifest: "json"
}
3. async-component-flags — 冗長な async フラグの削除
IAsyncContentCreation インターフェースが実装されている場合、manifest.json 内の async フラグは冗長になるため削除します。
manifest.json での対応:
// 修正前
{
"sap.ui5": {
"rootView": {
"viewName": "my.app.view.Main",
"type": "XML",
"async": true
},
"routing": {
"config": {
"async": true,
...
}
}
}
}
// 修正後
{
"sap.ui5": {
"rootView": {
"viewName": "my.app.view.Main",
"type": "XML"
},
"routing": {
"config": {
...
}
}
}
}
4. async-component-flags — async: false の削除
async: false が明示的に設定されている場合、非同期ローディングを妨げるため削除する必要があります。
5. Component.js 内のインライン manifest の対応
manifest が別ファイルの manifest.json ではなく Component.js にインラインで定義されている場合、同様の修正をインライン manifest オブジェクトに適用します。
なお、この場合も interfaces は metadata 内に配置します。インライン manifest プロパティと兄弟関係となり、両方とも metadata 配下にネストされます:
// 修正前
metadata: {
manifest: {
"sap.ui5": {
"rootView": {
"async": true,
...
}
}
}
}
// 修正後
metadata: {
manifest: {
"sap.ui5": {
"rootView": {
...
}
}
},
interfaces: ["sap.ui.core.IAsyncContentCreation"] // ← metadata の内側に配置
}
実装手順
- Component.js ファイルを読み込む
- 構文スタイルを確認する(
sap.ui.defineまたは ES6 クラス) async-component-flagsエラーへの対応:IAsyncContentCreationインターフェースがすでに宣言されているか確認- 宣言されていない場合、
interfaces: ["sap.ui.core.IAsyncContentCreation"]をmetadata: { }オブジェクト内のプロパティとして追加する(manifestの兄弟要素として配置し、metadata自体の兄弟要素にしないこと) manifest: "json"が宣言されているか確認し、なければ追加
- 配置を確認:
interfacesはmetadata:より 1 段深くインデントされているか確認し、同じレベルにある場合は誤り - manifest.json(またはインライン manifest)に冗長な async フラグがないか確認
- rootView および routing/config から
asyncプロパティを削除 - 更新したファイルを書き込む
- ゲートスクリプトを実行して検証する:
node <skill-dir>/scripts/verify-component.js <project-root>— 終了コード 0 で終わること
修正例
以下のリンター出力が得られた場合:
Component.js:5:1 error Component is not configured for asynchronous loading. async-component-flags
Component.js の変換:
// 修正前
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json"
},
init: function() {
UIComponent.prototype.init.apply(this, arguments);
// ...
}
});
});
// 修正後 — interfaces は metadata の内側に配置し、init や metadata の兄弟要素にしないこと
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json",
interfaces: ["sap.ui.core.IAsyncContentCreation"]
},
init: function() {
UIComponent.prototype.init.apply(this, arguments);
// ...
}
});
});
備考
IAsyncContentCreationインターフェースは UI5 1.89 で導入されました。minUI5Versionが互換性を満たしていることを確認してください。- インターフェースを追加する際は、適切な非同期ローディングのために
manifest: "json"も存在することを確認してください。 - このインターフェースを追加すると
async: trueフラグは冗長になり、安全に削除できます。 - UIComponent(Component だけでなく)を継承するコンポーネントでも
IAsyncContentCreationを使用できます。 - カスタムベースコンポーネントを継承しており、そのベースコンポーネントがすでに
IAsyncContentCreationを実装している場合は変更不要です。 IAsyncContentCreationと manifest v2 の関係: これらは独立した事項です。manifest の_versionを"2.0.0"に更新しても、非同期コンテンツ作成は自動的に有効になりません。Component.js にIAsyncContentCreationを明示的に実装する必要があります。逆に、IAsyncContentCreationを追加しても manifest v2 は必須ではありません。
関連スキル
- fix-manifest-json:
IAsyncContentCreationを追加した場合、manifest.json のasyncフラグが冗長になります。_versionの更新、async プロパティの削除、ルーティング設定のリネームには fix-manifest-json を使用してください。 - fix-js-globals: Component.js がグローバルアクセスパターン(例:
sap.ui.getCore())を使用している場合、fix-js-globals を使用して適切なモジュールインポートに変換してください。
原文(English)を表示
Fix Component.js Async Configuration
This skill fixes Component.js async configuration issues that the UI5 linter detects but cannot auto-fix because they may require understanding of the component's loading behavior.
Linter Rules Handled
| Rule ID | Message Pattern | This Skill's Action |
|---|---|---|
async-component-flags |
Component is not configured for asynchronous loading | Add IAsyncContentCreation interface |
async-component-flags |
Component does not specify that it uses the descriptor via the manifest.json file | Add manifest: "json" |
async-component-flags |
Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag ... should be removed | Remove async flag from manifest |
async-component-flags |
The 'async' property at '...' must be removed | Remove async: false |
no-removed-manifest-property |
Property '...' has been removed in Manifest Version 2 | Remove async property |
When to Use
Apply this skill when you see linter output like:
Component.js:5:1 error Component is not configured for asynchronous loading. async-component-flags
Component.js:5:1 warning Component does not specify that it uses the descriptor via the manifest.json file async-component-flags
Component.js:10:5 warning Component implements the sap.ui.core.IAsyncContentCreation interface. The redundant 'async' flag at '/sap.ui5/rootView/async' should be removed async-component-flags
manifest.json:25:9 error The 'async' property at '/sap.ui5/rootView/async' must be removed async-component-flags
Important during full modernization workflows: Also apply this skill unconditionally to every Component.js, even if the linter did not flag async-component-flags. The linter can only detect the missing interface AFTER redundant async: true flags are removed from manifest.json — so in early modernization phases the error won't appear yet. Always add IAsyncContentCreation proactively.
Critical Rules
Never Import IAsyncContentCreation
IAsyncContentCreation is a marker interface — the UI5 runtime checks for its name as a string in the interfaces array. It must NOT be imported as a module dependency. Adding it to the sap.ui.define dependency array causes a runtime error because sap/ui/core/IAsyncContentCreation is not a loadable module.
// WRONG — do NOT import it
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/core/IAsyncContentCreation" // ← WRONG: will fail at runtime
], function(UIComponent, IAsyncContentCreation) {
...
});
// CORRECT — only reference it as a string in interfaces
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json",
interfaces: ["sap.ui.core.IAsyncContentCreation"] // ← string reference only
}
});
});
If you see "sap/ui/core/IAsyncContentCreation" in an existing dependency array, remove it and its corresponding function parameter.
Correct Placement of interfaces
interfaces is a property of the metadata object — it must be nested inside metadata: { }. The UIComponent.extend() config object has two levels:
UIComponent.extend("name", {
metadata: { ← level 1: component config
manifest: "json", ← level 2: metadata properties
interfaces: [...] ← level 2: THIS IS WHERE interfaces GOES
},
init: function() {} ← level 1: component config
});
The UI5 runtime only reads interfaces from the metadata object. Placing it at level 1 (as a sibling of metadata) silently fails — the component will not be recognized as async.
After writing your edit, verify: is interfaces indented one level deeper than metadata:? If not, you put it in the wrong place.
Fix Strategy
1. async-component-flags - Add IAsyncContentCreation Interface
The IAsyncContentCreation interface is the modern way to declare that a component loads content asynchronously.
Correct — interfaces nested inside metadata:
// Before
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json"
}
});
});
// After
sap.ui.define([
"sap/ui/core/UIComponent"
], function(UIComponent) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json",
interfaces: ["sap.ui.core.IAsyncContentCreation"]
}
});
});
WRONG — interfaces at the wrong nesting level:
// WRONG — interfaces as a sibling of metadata (level 1 instead of level 2)
return UIComponent.extend("my.app.Component", {
interfaces: ["sap.ui.core.IAsyncContentCreation"], // ← WRONG: outside metadata
metadata: {
manifest: "json"
}
});
2. async-component-flags - Add Manifest Declaration
If the component doesn't declare it uses a manifest, add manifest: "json" to the metadata.
// Before
metadata: {
// no manifest declaration
}
// After
metadata: {
manifest: "json"
}
3. async-component-flags - Remove Redundant Async Flags
When IAsyncContentCreation interface is implemented, the async flags in manifest.json become redundant and should be removed.
In manifest.json:
// Before
{
"sap.ui5": {
"rootView": {
"viewName": "my.app.view.Main",
"type": "XML",
"async": true
},
"routing": {
"config": {
"async": true,
...
}
}
}
}
// After
{
"sap.ui5": {
"rootView": {
"viewName": "my.app.view.Main",
"type": "XML"
},
"routing": {
"config": {
...
}
}
}
}
4. async-component-flags - Remove async: false
If async: false is explicitly set, this must be removed as it prevents asynchronous loading.
5. Handle Inline Manifest in Component.js
If the manifest is defined inline in Component.js (not in a separate manifest.json), apply the same fixes to the inline manifest object. Note that interfaces still goes inside metadata — it is a sibling of the inline manifest property, both nested under metadata:
// Before
metadata: {
manifest: {
"sap.ui5": {
"rootView": {
"async": true,
...
}
}
}
}
// After
metadata: {
manifest: {
"sap.ui5": {
"rootView": {
...
}
}
},
interfaces: ["sap.ui.core.IAsyncContentCreation"] // ← still INSIDE metadata
}
Implementation Steps
- Read the Component.js file
- Determine the syntax style (sap.ui.define or ES6 class)
- For
async-component-flagserrors:- Check if
IAsyncContentCreationinterface is already declared - If not, add
interfaces: ["sap.ui.core.IAsyncContentCreation"]as a property inside themetadata: { }object (sibling ofmanifest, NOT sibling ofmetadataitself) - Check if
manifest: "json"is declared, add if missing
- Check if
- Verify placement:
interfacesmust be indented one level deeper thanmetadata:— if it's at the same level, it's wrong - Check the manifest.json (or inline manifest) for redundant async flags
- Remove
asyncproperties from rootView and routing/config - Write the updated files
- Run the gate script to verify:
node <skill-dir>/scripts/verify-component.js <project-root>— must exit 0
Example Fix
Given linter output:
Component.js:5:1 error Component is not configured for asynchronous loading. async-component-flags
Component.js transformation:
// Before
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json"
},
init: function() {
UIComponent.prototype.init.apply(this, arguments);
// ...
}
});
});
// After — interfaces goes INSIDE metadata, not next to init/metadata
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
"use strict";
return UIComponent.extend("my.app.Component", {
metadata: {
manifest: "json",
interfaces: ["sap.ui.core.IAsyncContentCreation"]
},
init: function() {
UIComponent.prototype.init.apply(this, arguments);
// ...
}
});
});
Notes
- The
IAsyncContentCreationinterface was introduced in UI5 1.89 - ensure minUI5Version is compatible - When adding the interface, also ensure
manifest: "json"is present for proper async loading - The interface makes
async: trueflags redundant - they can be safely removed - Components that extend UIComponent (not just Component) can use IAsyncContentCreation
- If the component inherits from a custom base component that already implements IAsyncContentCreation, no changes are needed
IAsyncContentCreationvs manifest v2: These are independent concerns. Updating manifest_versionto"2.0.0"does NOT automatically enable async content creation —IAsyncContentCreationmust still be explicitly implemented in Component.js. Conversely, addingIAsyncContentCreationdoes not require manifest v2.
Related Skills
- fix-manifest-json: When adding
IAsyncContentCreation, the manifest.jsonasyncflags become redundant — use fix-manifest-json to update_version, remove async properties, and rename routing configuration - fix-js-globals: If Component.js uses global access patterns (e.g.,
sap.ui.getCore()), use fix-js-globals to convert them to proper module imports
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。