SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.9k stars 1.23k forks source link

CDN: source map no longer applied expectedly since 1.120 with Chromium browsers #4035

Closed boghyon closed 1 month ago

boghyon commented 2 months ago

URL (minimal example if possible)

https://embed.plnkr.co/NKOfisfY7w0MOiX8?show=manifest.json,preview:?sap-ui-xx-componentPreload=off

Steps to reproduce the problem

  1. Open the browser console (F12) in the sample above.
  2. Let the framework throw an Error, e.g. by adding a space to the manifest.json section /sap.ui5/commands/MyRefresh/shortcut: "F5" --> "F5 " which is not an allowed character there.
  3. Ensure that the preview is reloaded. Observe the error reported in the console.

What is the expected result?

The error in the console includes a link to the place via the source map where the Error was thrown. In the sample above, the link should lead to the ShortcutHelper-dbg.js. This is currently the case until UI5 1.119.

What happens instead?

The error shows a link to the library-preload.js instead since UI5 1.120, but only if the framework is bootstrapped from the CDN URL. Building the UI5 SDK from rel-1.120 and bootstrapping from http://localhost:8000/resources/sap-ui-core.js shows the ShortcutHelper-dbg.js link in the console expectedly.

Any other information? (attach screenshot if possible)

The library-preload.js.map content from the CDN seems to differ from the locally built library-preload.js.map.

codeworrior commented 2 months ago

I assume that "locally built" means built with the ui5 cli alone? There's indeed a difference between the library-preload.js.map when it's built locally (with ui5 cli on openui5/src/sap.ui.core) compared to the version on the CDN.

But that difference is caused by differences between the public and the SAP internal build. Internally, we merge a few legacy sources into the build result for sap.ui.core (and others). Those sources are legacy and have been deprecated before UI5 went open source. We therefore decided to omit them from the OpenUI5 repository and only kept them internally for compatibility reasons.

I can confirm that the source maps work as expected for 1.119.0 and don't work as expected in 1.120.0. But I could not easily confirm that source maps work when build locally.

Only when I used @ui5/cli 3.4.0 (which was used in 1.119.0), the source maps show ShortcutHelper-dbg.js in the stack trace again. With more recent tooling, a local build for me shows the same behaviour as the CDN.

Another observation: with Safari, source maps even work in 1.120 when loaded from the CDN.

boghyon commented 2 months ago

I can confirm also that the source maps work with Firefox in UI5 1.120 too.
By "locally built", I meant the resources built and served from npm run sdk.

PetyaMarkovaBogdanova commented 2 months ago

Hi @boghyon , thank you for your submission! I have created an internal ticket (DINC0139775) for colleagues to observe the addressed issue. Best regards, Petya Markova. (UI5 Dispatcher)

RandomByte commented 1 month ago

I created a fix on UI5 Tooling side: https://github.com/SAP/ui5-builder/pull/1014

For sap.ui.core this is ultimately caused the added handling for input source maps (since @ui5/cli v3.7.0) in combination with a file containing only comments (for which the minify task will create a source map with no mappings) in OpenUI5 1.118.0: sap/ui/model/odata/v4/ts.js

RandomByte commented 1 month ago

Fix in UI5 Tooling got released with @ui5/builder@v3.4.1 and @ui5/cli@v3.10.1.

All affected and currently maintained UI5 code lines have been updated to use this version for their next patch release, as well as the next UI5 minor release. Therefore closing this issue for the time being. Thanks for spotting this!