ES 模块 (.mjs) 格式的 UI5 控制器
UI5 controller in ES Module (.mjs) format
是否可以以 ES 模块 (.mjs
) 格式编写 UI5 控制器以获得严格模式和默认启用的其他 ES 模块功能?
关于UI5控制器对ES Modules的支持,截至2020年Q4,SAP UI5团队response如下:
The ui5loader
supports only AMD or native global scripts, but no ES6 modules. A two-way, seamless integration of ES6 modules and AMD (without transpiling) is tricky, as ES6 has a different dependency resolution model than AMD (the most tricky part is to make AMD's asynchronous dependency resolution transparent for ES6 code). We experimented a while with such a mixture, but don't see a satisfying solution.
关于 UI5 中的严格模式本身,according SAP UI5 团队,在 OpenUI5 中,严格模式由活动的 ESLint 规则确保,因此可以在任何地方使用,而在SAPUI5 并非所有代码都使用严格模式。因此,最好应用“use strict”;仅在功能范围内,以避免潜在的问题。
是否可以以 ES 模块 (.mjs
) 格式编写 UI5 控制器以获得严格模式和默认启用的其他 ES 模块功能?
关于UI5控制器对ES Modules的支持,截至2020年Q4,SAP UI5团队response如下:
The
ui5loader
supports only AMD or native global scripts, but no ES6 modules. A two-way, seamless integration of ES6 modules and AMD (without transpiling) is tricky, as ES6 has a different dependency resolution model than AMD (the most tricky part is to make AMD's asynchronous dependency resolution transparent for ES6 code). We experimented a while with such a mixture, but don't see a satisfying solution.
关于 UI5 中的严格模式本身,according SAP UI5 团队,在 OpenUI5 中,严格模式由活动的 ESLint 规则确保,因此可以在任何地方使用,而在SAPUI5 并非所有代码都使用严格模式。因此,最好应用“use strict”;仅在功能范围内,以避免潜在的问题。