Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
boghyon opened this issue Apr 28, 2024 · 5 comments
Closed
Assignees

Comments

@boghyon
Copy link
Contributor

boghyon commented Apr 28, 2024

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
Copy link
Member

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
Copy link
Contributor Author

boghyon commented Apr 29, 2024

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.

@boghyon boghyon changed the title CDN: source map no longer applied expectedly since 1.120 CDN: source map no longer applied expectedly since 1.120 with Chromium browsers Apr 29, 2024
@PetyaMarkovaBogdanova
Copy link
Contributor

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 added a commit to SAP/ui5-builder that referenced this issue May 10, 2024
… map

If a resource features an empty source map (which is not the same as
having no source map), the bundle's source map generation needs to
handle this differently from cases where mappings exist.

It must not prefix the empty mapping with a string "AAAA,"
since the danglíng comma will result in a corrupt source map.

However, it should still add the mapping for the first line/column
"AAAA". Otherwise the source map of the preceding module in the bundle
would be applied.

Resolves the root cause of SAP/openui5#4035
DINC0139775
@RandomByte
Copy link
Member

I created a fix on UI5 Tooling side: SAP/ui5-builder#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 added a commit to SAP/ui5-builder that referenced this issue May 13, 2024
… map

If a resource features an empty source map (which is not the same as
having no source map), the bundle's source map generation needs to
handle this differently from cases where mappings exist.

It must not prefix the empty mapping with a string "AAAA,"
since the danglíng comma will result in a corrupt source map.

However, it should still add the mapping for the first line/column
"AAAA". Otherwise the source map of the preceding module in the bundle
would be applied.

Resolves the root cause of SAP/openui5#4035
DINC0139775
RandomByte added a commit to SAP/ui5-builder that referenced this issue May 13, 2024
… map

If a resource features an empty source map (which is not the same as
having no source map), the bundle's source map generation needs to
handle this differently from cases where mappings exist.

It must not prefix the empty mapping with a string "AAAA,"
since the danglíng comma will result in a corrupt source map.

However, it should still add the mapping for the first line/column
"AAAA". Otherwise the source map of the preceding module in the bundle
would be applied.

Resolves the root cause of SAP/openui5#4035
DINC0139775
RandomByte added a commit to SAP/ui5-builder that referenced this issue May 13, 2024
…ource map

If a resource features an empty source map (which is not the same as
having no source map), the bundle's source map generation needs to
handle this differently from cases where mappings exist.

It must not prefix the empty mapping with a string "AAAA,"
since the danglíng comma will result in a corrupt source map.

However, it should still add the mapping for the first line/column
"AAAA". Otherwise the source map of the preceding module in the bundle
would be applied.

Resolves the root cause of SAP/openui5#4035
DINC0139775

(cherry picked from commit 1228db7)
RandomByte added a commit to SAP/ui5-builder that referenced this issue May 14, 2024
…ource map

If a resource features an empty source map (which is not the same as
having no source map), the bundle's source map generation needs to
handle this differently from cases where mappings exist.

It must not prefix the empty mapping with a string "AAAA,"
since the danglíng comma will result in a corrupt source map.

However, it should still add the mapping for the first line/column
"AAAA". Otherwise the source map of the preceding module in the bundle
would be applied.

Resolves the root cause of SAP/openui5#4035
DINC0139775

(cherry picked from commit 1228db7)
@RandomByte
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants