SAP / ui5-tooling

An open and modular toolchain to develop state of the art applications based on the UI5 framework
https://sap.github.io/ui5-tooling
Apache License 2.0
465 stars 71 forks source link

Consider project dependencies for sap-ui-cachebuster-info.json generation #373

Open BenReim opened 5 years ago

BenReim commented 5 years ago

Expected Behavior

All run-time resources - including project dependencies - shall be considered cachebusting relevant.

Current Behavior

Currently, project dependencies are not considered – even when they are part of the build result, e.g. when running a build with the --all flag. I’m not sure whether this is done intentionally but see issues that could arise from this when relying on the cache busting mechanism. For instance, a browser would not be informed when an app dependency has changed in any way.

In case of the ui5lab-app sample, the browser might load a cached library-preload.js file of the ui5lab-library-simple dependency, which might not be compatible with the current app implementation.

Steps to reproduce the issue

  1. Clone ui5lab sample library git clone https://github.com/UI5Lab/UI5Lab-library-simple

  2. Update to latest version of @ui5/cli npm install @ui5/cli@latest --save-dev

  3. Build with generateCachebusterInfo task ui5 build -a --include-task="generateCachebusterInfo"

  4. Check the content of the generated sap-ui-cachebuster-info.json file dist folder --> Project dependencies (like the ui5-library-sample) are not being considered.

RandomByte commented 5 years ago

CC @petermuessig

petermuessig commented 5 years ago

@BenReim the open-source application cachebuster implementation is aligned with the internal cachebuster implementation for which only the application resources are considered. For the regular runtime resources the runtime cachebuster (src="resources/sap-ui-cachebuster/sap-ui-core.js") should be used but indeed for static applications including libraries this runtime cachebuster is not available and therefore I can see that this might be needed as well.

BTW - I have more a side question regarding the runtime: where do you deploy this library? is there also the server side component available which can handle the application cachebuster requests?

BenReim commented 5 years ago

@petermuessig Thanks for explaining that. I was actually using the cachebusting feature provided the grunt-sapui5-bestpractice-build before - and as you mentioned already - that plugin also didn’t consider static application / library sources. I guess one reason for that might also be that the grunt set-up cannot handle dependencies in the same way as the ui5-tooling does now.

Regarding the deployment, its pretty straight forward: our app bundles are deployed to the SAP Cloud Platform. Although I read somewhere in the docs that the ui5 application cache buster is only supported on NetWeaver, we’ve found that the cachebusting is actually working very well for us on SCP. Using the app cache buster helped us to solve caching-related issues users would run into previously.

petermuessig commented 5 years ago

@matz3 @RandomByte in this case the best way would be to scan the dist folder rather than the virtual workspace to identify all resources + built dependency resources in the dist folder and to create the cachebuster index out of it. This is another example for what the dist folder would be interesting to have at build time...