如何控制UI5中的导入顺序?

huangapple go评论79阅读模式
英文:

How to control import order in UI5?

问题

我遇到了以下问题:

“Shimmed Module C 依赖于 Shimmed Module B,而 Shimmed Module B 依赖于 Shimmed Module A”。

这些 Shim(模块)是通过 ui5.yaml 文件中的标准配置加载的。由于它们不遵循 UMD(通用模块定义),它们的内部依赖对 UI5 是透明的。

最终,SM A 是控制器的依赖项。但是,要成功使用它,SM BSM C 必须事先加载。

我如何能够确保成功导入并保证顺序呢?
并行导入对我来说行不通,因为它们可能或可能不按所期望的顺序进行。

内联脚本/同步导入调用也不受欢迎,因为它们很容易违反更严格的 CSP(内容安全策略)。

非常感谢任何帮助 - 在此提前致以感谢!

英文:

I am experiencing the following issue:

Shimmed Module C depends on Shimmed Module B which depends on Shimmed Module A.

Shims are loaded trough standard configuration in the ui5.yaml file. As they do not follow UMD, their inner deps are transparent to UI5.

At the end, SM A is dependency of a controller. For successful use however, SM B & SM C must've been loaded beforehand.

How can I accomplish successful import with guarantees of the order?
Parallel imports don't do the trick for me as they may or may not follow the desired order.

Inline scripts / synchronous import calls are also undesired, as they easily violate stricter CSPs.

Any help is greatly appreciated - thanks in advance!

答案1

得分: 0

I managed to solve the issue using the sap.ui.loader & the official docs on AMD. Turns out, each shim can define deps section, where one can describe the inner dependencies of the packages. Using this, I could define the proper relations between them. Once this was done, the order of import happened automatically.

英文:

I managed to solve the issue using the sap.ui.loader & the official docs on AMD. Turns out, each shim can define deps section, where one can describe the inner dependencies of the packages. Using this, I could define the proper relations between them. Once this was done, the order of import happened automatically.

huangapple
  • 本文由 发表于 2023年4月11日 16:17:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75983796.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定