sap-ui-core.js incorrectly alters URL (in new build)
See original GitHub issueExpected Behavior
Where ever I place sap-ui-core.js
, this becomes the default resource root for everything.
e.g. if the path to sap-ui-core.js is:
/resources/v1.2.3/sap-ui-core.js
then the path to sap.ui.core preload is:
/resources/v1.2.3/sap/ui/core/library-preload.js
Current Behavior
Because “resources” is in the path, it looks as if it is assumed to be the default root.
e.g. When the path to sap-ui-core.js is:
/resources/v1.2.3/sap-ui-core.js
the path to sap.ui.core preload is presumed to be:
/resources/sap/ui/core/library-preload.js
So the runtime fails to load.
Steps to reproduce the issue
- Clone openui5-sample-app
- npm install
- ui5 build -a
- Start a (http server) pointing to
./dist
and verify app starts as expected - Copy contents of resources into a sub-folder of resources. E.g.
/resources/v1.2.3
- Correct path in index.html to load sap-ui-core from
/resources/v1.2.3/sap-ui-core.js
Result:
With the browsers dev tools open, you can see sap-ui-core.js loads fine (as expected), but then the client attempts to load all the preloads from /resources/*
(and not /resources/v1.2.3/*
)
Note: For the purposes of this ticket, everything was tested with 1.63. However, right now (until we’ve finished our migration to ui5-tooling) we primarily carry out tests on version 1.58.4 where we can compare the older “bower” version with the newer ui5-tooling variant. As such, we can see this issue only occurs with the ui5-tooling variant and not with the older bower version.
Context
- UI5 Module Version 1.2.1
- Node.js Version: v10.15.1
- npm Version: n/a
- OS/Platform: Windows 10
- OpenUI5 1.63
Affected components (if known)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
I had taken another look at this, a few days ago, but didn’t post un update here.
I meanwhile think this is related to https://github.com/SAP/openui5/commit/ccbce4e88c2aae3021b70874f7e7ce373e166394. With this change, script tags with
id=sap-ui-bootstrap
are not only preferred, but their URL is no longer checked for well known names, only for aresources/
segment. Preferring the scripts with theid
makes sense, but even then we should check the path for well known names first and only if that fails, fall back to theresources/
segment.I did a compare between the bower built version and the ui5-tooling build version of some key files:
I was amazed to see that although these were both built with two entirely different tools, the output is impressively similar. Meaning I’m even more confused as to how I don’t have this issue when I use the bower variant of 1.58.4, but I do, when I use the ui5-tooling variant of 1.58.4.
The only difference I found was in sap-ui-core.js where the Mozilla polyfill for Object.assign is no longer at the top (almost) of the file. Hardly a smoking gun.
If there is anything more I can do on my side, please let me know. But this issue no longer blocks me thanks to the great tip from @codeworrior