UI5 Tooling: Specifying libraries dependencies in ui5.yaml
pubmikeb opened this issue · 3 comments
Playing with UI5 Tooling, I see that the ui5.yaml config file contains a framework library section, where we supposed to specify UI5 app dependencies, e.g. sap.m
, sap.ui.core
etc.:
specVersion: "3.2"
type: application
metadata:
name: com.myApp
framework:
name: OpenUI5
version: 1.124.0
libraries:
- name: sap.m
- name: sap.ui.core
My questions:
-
Should the
framework/libraries
section of ui5.yaml be identical to thesap.ui5/dependencies/libs
one of manifest.json? -
If I understand it correctly, these
framework/libraries
section is used to incorporate these libs intoComponent-preload.js
. Is it a correct assumption? -
Should I specify this
libraries
section at all in case, if I consume UI5 lib from the CDN?
Hi @pubmikeb ,
- Should the framework/libraries section of ui5.yaml be identical to the sap.ui5/dependencies/libs one of manifest.json?
Ideally, yes. The framework
part of the ui5.yaml
gives hints on how to build you app, while the manifest.json
gives "hints" during bootstraping of the UI5 core which libs to download, eventually prefetch or lazy load.
- https://sap.github.io/ui5-tooling/stable/pages/Configuration/#framework-and-version
- Go to
sap.ui5
section and look for dependencies property https://sapui5.hana.ondemand.com/sdk/#/topic/be0cf40f61184b358b5faedaec98b2da
- If I understand it correctly, these framework/libraries section is used to incorporate these libs into Component-preload.js. Is it a correct assumption?
- Not into the Component-preload, but yes, it bundles those libs along with your app, BUT only for self contained build
- Should I specify this libraries section at all in case, if I consume UI5 lib from the CDN?
- Yes, you might need them for local development, for example
@d3xter666, thanks a lot for the detailed explanation!
Regarding the first answer, wouldn't be great to add to UI5 Tooling the possibility to «inherit» the values of manifest.json's sap.ui5/dependencies/libs
by default?
So, if nothing is specified in framework/libraries
, then UI5 Tooling tries reading sap.ui5/dependencies/libs
from manifest.json. This might help to avoid unintentional inconsistency between sap.ui5/dependencies/libs
and framework/libraries
.
- Should I specify this libraries section at all in case, if I consume UI5 lib from the CDN?
- Yes, you might need them for local development, for example
Adding to this statement, when consuming SAPUI5 via CDN during development it is not needed to declare the dependencies in the ui5.yaml.
Actually, I would even advise against it since a miss match in the SAPUI5 version of both sources could cause unexpected behavior. Many UI5 project templates therefore use multiple ui5.yaml configuration files to distinguish between CDN and local SAPUI5 dependency usage.
Regarding the first answer, wouldn't be great to add to UI5 Tooling the possibility to «inherit» the values of manifest.json's
sap.ui5/dependencies/libs
by default?So, if nothing is specified in
framework/libraries
, then UI5 Tooling tries readingsap.ui5/dependencies/libs
from manifest.json. This might help to avoid unintentional inconsistency betweensap.ui5/dependencies/libs
andframework/libraries
.
As Yavor outlined we try to have a clear separation between "runtime" and "buildtime" dependencies in the hope that this makes it easier for developers to understand and maintain the two configurations correctly.
Some examples where it might get tricky when using manifest.json as a fallback:
- Applications usually need to declare a theme dependency (see for example the openui5-sample-app). While this could also be expressed in manifest.json using the
supportedThemes
attribute, it is not really the same as explicitly declaring a dependency. So applications would often have to declare at least their theme dependencies in the ui5.yaml. Should we ignore the other dependencies in manifest.json then? (since something is specified inframework/libraries
) - The ui5.yaml configuration allows to flag dependencies as "development" dependencies, which are required for the purpose of local testing. For example the sap.ushell library is often required for a local sandbox setup. These dependencies must not be declared in the manifest.json since that might lead to loading of unnecessary libraries at runtime. I fear that by blurring the line between runtime and buildtime dependencies, this mistake is more likely to be made.
- The manifest.json configuration might not only list SAPUI5 libraries but also custom or third-party UI5 libraries. I'm not sure how UI5 Tooling could effectively differentiate between the two in order to correctly inform users about missing or misspelled dependencies. Custom UI5 libraries are sometimes not required during development so their absence can be ignored. But what if it's a misspelled framework library?
I agree that inconsistency is an issue. For our framework libraries we therefore have an internal validation that ensures the ui5.yaml contains at least all dependencies listed in the manifest.json. But with regards to 3., such a check might not work for projects relying on custom UI5 libraries.