ui5-tooling
ui5-tooling copied to clipboard
Configuration in ui5.yaml file for the createDebugFiles Task
Expected Behavior
I would like to be able to write additional configuration in the ui5.yaml file for the createDebugFiles task to:
- skip a source file from being created with debug file
- Example: there's a source file in our library, let's call it bootstrap.js. The file is used only for development time. Once the library is built, the content of this file is replaced completely but saved still under the same path. We also create a bundle for being used under debug mode. This means that we create two bundles, bootstrap.js and bootstrap-dbg.js. We need a configuration to skip the creation of the bootstrap-dbg.js otherwise the dbg file is created by copy the content of the bootstrap.js bundle which is different than the bootstrap-dbg.js bundle.
- specify the bundles which are created in createBundle task to be created with debug files
- some of our bundle files should also be created with debug files. Because they don't appear as source files but only be created in the createBundle task, they are currently not being considered in the createdDebugFiles task.
Current Behavior
Debug files are created for each and every javascript source file. There's no way to add additional and to skip the existing source files.
Affected components
- [x] ui5-builder
- [ ] ui5-server
- [ ] ui5-cli
- [ ] ui5-fs
- [ ] ui5-project
- [ ] ui5-logger
After discussion with @stopcoder:
Re 1: A possible solution would be to add a configuration option (builder.debugFiles.patterns
- array or string) for the pattern that is handed over to createDebugFiles
in Application- and LibraryBuilder
Re 2: A possible solution would be to add a bundle configuration parameter like "createDebugFile" to automatically create a -dbg.js
version of a bundle.
This seems to be required for all bundles that do not have any fallback logic in the UI5 framework when running an application in sap-ui-debug mode (to be confirmed @codeworrior).
Moreover, the -dbg.js
version should not be minified. But when splitting a bundle into multiple parts (via numberOfParts
config), that splitting should happen evenly for the minified sourced (independently from the -dbg.js
sources).
Also @codeworrior: Can you shed some light into how something like this worked with the maven tooling?
@matz3 mentioned that there is actually a fallback logic from x-dbg.js
to x.js
.
Currently I can't verify this with the openui5-sample-app due to the missing window["sap-ui-optimized"] = true;
flag in sap-ui-core.js
. This probably broke with SAP/ui5-builder#25
For the standard bundles that the UI5 runtime handles automatically (Component-preload.js, library-preload.js
), there never have been any -dbg
files.
- in full debug mode (
sap-ui-debug=true
), the runtime skips the preload files and loads the individual-dbg
files. - in partial debug mode (
sap-ui-debug=some/pattern/*
), the normal preload files are loaded but anything matching the pattern is ignored in the preloads and the individual-dbg
files are loaded instead
For other bundles that are bootable (like sap-ui-core.js
or sap/fiori/core-min-0.js
), a -dbg
version was created by manual configuration. Usually, that -dbg
version did not contain the same content as the standard bundle, but only the code needed to establish the loader. Everything else was then required as individual -dbg
files. This kept the -dbg
files for the bundles as small as possible.
For non-standard bundles that are not bootable (like core-min-1...3
or core-ext
), there was no common approach. The FLP for example checked itself for sap-ui-debug
mode and then skipped the requests for those files.
@codeworrior thank you for the clear clarification about loading bundle in debug mode.
After reading your reply, I think that the 2 feature requirements need to be reconsidered and reformulated.
-
skip a source file from being created with debug file: I think it's currently not needed to have an extra option for it. Instead, the
createDebugFiles
task should check whether the-dbg.js
path is written already by the previous tasks and only create the debug files if the path isn't occupied yet. -
specify the bundles which are created in createBundle task to be created with debug files: I need to check in FLP to see whether it's correct to load the
core-min-*-dbg.js
in debug mode. I think we shouldn't load them in debug mode and need to do a change in FLP.
Re 1: We agreed today to try that and measure any performance changes that might be caused by the additional file stats.
Implementing 1 IMO would imply to always do a 'clean' build, wouldn't it? Only checking for sources wouldn't work in case a bundle-dbg.js is created by configuration. Or are resources in target folders never taken from the file system, only created via APIs?
Or are resources in target folders never taken from the file system, only created via APIs?
Yes, files from target are not read at all. At least when performing the build from the CLI. By using the builder directly, this might be different.
A PR SAP/ui5-builder#43 is made for the 1st point.