Skip to content

Commit

Permalink
[INTERNAL] Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Günter Klatt <[email protected]>
  • Loading branch information
flovogt and KlattG committed Jul 12, 2024
1 parent fdc0ace commit 87cb717
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions docs/pages/Builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ To get a list of all available processors, please visit [the API reference](http
JavaScript port of the "legacy" Maven/Java based bundle tooling.


### JavaScript files requiring top level scope
UI5 Tooling packages JavaScript files that require "top level scope" as a string, as long as your project is using a Specification Version lower than `4.0`. In this case, the respective code is evaluated using [`eval`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) at runtime.
### JavaScript Files Requiring Top Level Scope
UI5 Tooling packages JavaScript files that require "top level scope" as a string, provided your project uses a Specification Version lower than `4.0`. In this case, the code is evaluated using [`eval`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) at runtime.

This behavior ensures that the script works as expected, e.g. with regards to implicitly used globals. However this `eval` runtime feature will be discontinued with UI5 2.x because of security best practices (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) and to comply with stricter CSP settings (`unsafe-eval`). When your project defines [Specification Version 4.0](./Configuration.md#specification-version-40) or higher, files requiring top level scope are no longer part of the created bundle and an error is logged by UI5 Tooling. Therefore, please adjust your code with the help of one of the following options:
This ensures that the script works as expected, e.g. with regards to implicitly used globals. However, this `eval` runtime feature will be discontinued with UI5 2.x because of security best practices (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) and to comply with stricter CSP settings (`unsafe-eval`). If your project defines [Specification Version 4.0](./Configuration.md#specification-version-40) or higher, files requiring top level scope are no longer part of the created bundle and following error is logged by UI5 Tooling `Module myFancyModule requires top level scope and can only be embedded as a string (requires 'eval'), which is not supported with specVersion 4.0 and higher. For more information, see the UI5 Tooling documentation https://sap.github.io/ui5-tooling/stable/pages/Builder/#javascript-files-requiring-top-level-scope`. Therefore, please adjust your code with one of the following options:

**Option 1**: Use [ui5-tooling-modules](https://www.npmjs.com/package/ui5-tooling-modules) to bundle third-party `npm` packages. It converts files to `sap.ui.define` modules automatically.

Expand All @@ -173,6 +173,3 @@ sap.ui.define([], () => {
return myFancyModule;
})
```



0 comments on commit 87cb717

Please sign in to comment.