Open jbragiel opened 5 years ago
Due to this issue, the ui5 bootstrap will currently fail if the project has been build as self-contained
, but does not include all project dependencies.
ui5 build self-contained
The problematic dynamic require in sap.ui.core has since moved to https://github.com/SAP/openui5/blob/c1b7517b7857b58879c3e3473bbaeced10ea55a2/src/sap.ui.core/src/sap/ui/core/date/_Calendars.js#L18
Build with --include-all-dependencies
solved the issue for me with UI5 tooling v3.
Build with
--include-all-dependencies
solved the issue for me with UI5 tooling v3.
Do you mean that it now bundles the files, or that the app still works because the single files are loaded successfully? I don't see from the code how the bundling part would work now, even with v3.
Build with
--include-all-dependencies
solved the issue for me with UI5 tooling v3.Do you mean that it now bundles the files, or that the app still works because the single files are loaded successfully? I don't see from the code how the bundling part would work now, even with v3.
I didn't check the build content after I checked the application can run successfully... It actually packaged everything and I ended up with a nearly 300 MB web app with all the lib files that I did not need. The --include-all-dependencies doesn't really help.
The self-contained build is unusable because this issue is persistent. The website fails to load as it requires Gregorian.js, which is not included in the build.
@matz3, @RandomByte, is there an alternative solution to copying all scripts with the --include-all-dependencies option?
An easy, but cumbersome short-term workaround is to add an explicit dependency to any missing module (e.g. Gregorian) to your Component.js (or any other module of your app). Due to that dependency, the tooling will package the calendar in the self-contained bundle and it can be loaded at runtime.
If you want to avoid the (otherwise unnecessary) dependency in your application code, you might add a dedicate module DependencyDummy.js
to your app namespace which contains the missing dependencies in a sap.ui.define
call. As the self-contained bundle includes all resources from the app namespace (even if there's no path to them), this will also include the necessary dependencies.
Again, to emphasise it: this is a proposal for a workaround, not a solution. OpenUI5 itself hopefully soon chooses a different approach for calendar loading which then would make the workaround obsolete. But I can't name a due date for this.
Thanks @codeworrior for that workaround. The workaround seemed to work, but revealed another problem. The self-contained build doesn't include the language JSON files (for excample "en.json").
Without that file, the initialization of ODataV4-Model crashs with the message Cannot read properties of null (reading 'ca-gregorian')
So my current workaround to use the self-contained functionality is:
ui5 build self-contained --clean-dest --all
find dist/resources -type f ! \\( -name \\*.woff* -o -name \\*.json -o -name \\*.properties -o -name \\*.css -o -path \\*/chart.js/* -o -name \\*sap-ui-custom\\* \\) -exec rm {} + && find dist/resources -type d -empty -delete
This keeps my resources as low as possible and keeps the missing files in my build. I know that's not a nice workaround, but as I see, it's currently the only possible way.
Expected Behavior
There are no missing JavaScript files in sap-ui-custom.js used by an application.
Current Behavior
sap/ui/core/date/(Buddhist|Gregorian|Islamic|Japanese|Persian).js is not being included.
Steps to reproduce the issue
Take a look at the sap/ui/core/date/UniversalDate.js source from the openui5 repo: https://github.com/SAP/openui5/blob/6478939c8d4a89b3197647d6bcb99e3cb54f3047/src/sap.ui.core/src/sap/ui/core/date/UniversalDate.js#L90
There is a sap.ui.requireSync call on line 90 that loads a computed filepath:
sap.ui.requireSync("sap/ui/core/date/" + sCalendarType)
Due to the dynamic nature of this import, the build of sap-ui-custom.js won't include any of the possible files. I'm not sure if a fix would go into the build tools or into the SDK source code...
Context
ui5 --version
when using the CLI):1.5.2 (from C:\dev\master\htmlcommons-samples\openui-microbump\node_modules\@ui5\cli\bin\ui5.js)
v8.11.1
6.9.0
Windows 10 1809
N/A
N/A
Affected components (if known)
Log Output / Stack Trace