fix-cyclic-deps
Fix Cyclic Module Dependencies
This skill detects and resolves cyclic module dependencies that arise during UI5 modernization. When modernization phases convert global namespace access to proper sap.ui.define imports, new dependency edges are added to the module graph. If these edges create a circular import (A imports B, B imports A), the UI5 AMD loader returns undefined for the back-edge module.
The fix: replace the back-edge sap.ui.define dependency with a lazy sap.ui.require("path/to/Module") (synchronous form) at each call site. This retrieves the already-loaded module from the loader cache without creating a dependency edge.
Linter Rule
| Rule ID | Message Pattern | This Skill's Action |
|---|---|---|
| (none — structural) | Runtime: module is undefined despite correct import path |
Detect cycle in dependency graph, convert back-edge to lazy sap.ui.require() |
This skill is NOT triggered by a UI5 linter rule. It addresses a structural problem in the module dependency graph that the linter does not check. It is triggered as the final fix phase in the modernization workflow, or standalone when a developer encounters undefined modules at runtime.
When to Use
- In modernization workflow: As Phase 3, Step 3.3 (final step) after ALL other Phase 3 steps (3.1 globals/pseudo-modules + 3.2 blind-spots) complete. Multiple steps add
sap.ui.defineedges that can create cycles — running once at the end operates on the final dependency graph. - Standalone: When a module returns
undefinedat runtime despite a correct import path in thesap.ui.definearray. This is the classic symptom of a cyclic dependency. - After manual refactoring: When a developer adds a new
sap.ui.definedependency and gets an unexpectedundefined.