Skip to content

Latest commit

 

History

History
155 lines (114 loc) · 8.38 KB

0011-reuse-build-results.md

File metadata and controls

155 lines (114 loc) · 8.38 KB

RFC 0011 Reuse Build Results

Summary

When building a project, it should be possible to consume build results of dependencies in order to not having to build them again.

Based on the requested build, UI5 Tooling should be able to identify which dependencies are required to be built. It should also be able to determine whether a provided build result of a dependency can be used, or whether a new build is required.

To be checked: Would it be necessary/helpful if users/projects define a set of "build-time" dependencies which always have to be built? Or can UI5 Tooling determine this by itself from the set of provided dependencies?

Based on this concept, UI5 Tooling could implement a mechanism to cache build results automatically, transparently. This could then also be used by the ui5-server.

Motivation

As described in RFC 0010 UI5 Builder-Bundling Refactoring:

There is a gap in the minification process which causes a regression for some scenarios. JavaScript resources from other projects (dependencies) are not minified when not building the project with the --all flag. This is because the bundling task does not perform the minification but rather relies on this to be done by the minify task.

Requiring to always build a project with --all is not favorable due to performance reasons. Therefore, a solution is needed to still perform the needed minification steps for the mentioned resources.

To solve this, ui5-builder now detects which dependencies need to be built, before executing a project's build tasks. For this, every standard task can now define whether it requires access to dependencies or not. Custom task extensions can even specify which dependencies they need access to (also see RFC 0012 UI5 Tooling Extension API v3 - 3. Tasks Requiring Dependencies)

However, this implicit build of project dependencies still has a huge impact on the build time. Especially in cases where only the project itself should be built, it can now take many times longer. Therefore, we need to optimize the cases where building dependencies is actually required, and come up with means to re-use previous build results, removing the need to re-build all dependencies when making changes to only a few.

Detailed design

Reusable Build Results

Build Manifest

{
	"project": {
		"specVersion": "2.3",
		"type": "library",
		"metadata": {
			"name": "library.e"
		},
		"resources": {
			"configuration": {
				"paths": {
					"src": "resources",
					"test": "test-resources"
				}
			}
		}
	},
	"buildManifest": {
		"manifestVersion": "0.1",
		"timestamp": "2022-05-06T09:54:29.051Z",
		"versions": {
			"builderVersion": "3.0.0",
			"projectVersion": "3.0.0",
			"fsVersion": "3.0.0"
		},
		"buildConfig": {
			"selfContained": false,
			"jsdoc": false,
			"includedTasks": [],
			"excludedTasks": []
		},
		"id": "library.e",
		"version": "1.0.0",
		"namespace": "library/e",
		"tags": {
			"/resources/library/e/some.js": {
				"ui5:HasDebugVariant": true
			},
			"/resources/library/e/some-dbg.js": {
				"ui5:IsDebugVariant": true
			}
		}
	}
}

In a first step, the creation of a build manifest shall be limited to projects of types library and theme-library, until use cases for other types arise.

Tasks Requiring Dependencies

UI5 Tooling shall determine on a per-project level which dependencies need to be built before the project itself is built. This depends on the build-tasks that will be executed, and whether any of them require dependencies. If none of the tasks require dependencies, there is no need to build them. Unless of course the user explicitly requested a dependency to be part of the build output, e.g. by using the CLI parameters --include-dependency or --include-all-dependencies.

Standard Tasks

Task Name Description Type application Type library Type theme-library
generateVersionInfo Requires manifest.json of dependencies in order to list them in the generated sap-ui-version.json Task Disabled - -
generateResourcesJson Requires (built) runtime resources of dependencies in order to list them in the generated resources.json Task Disabled - -
generateJsdoc Requires designtime/api.json of dependencies - Task Disabled -
executeJsdocSdkTransformation Requires designtime/api.json of dependencies - Task Disabled -
generateApiIndex Task Disabled - -
buildThemes Requires theme resources of dependencies in order to build a library's theme. To be checked: Are the required resources already present in the dependency source? I.e. is it necessary to build them? - Enabled by Default Enabled by Default
generateThemeDesignerResources To read resources from sap.ui.core library. Possibly to resolve other Less imports? - Task Disabled Task Disabled
generateLibraryManifest Dependency access removed with SAP/ui5-builder#735 - Enabled by Default
generateComponentPreload Dependency access removed with SAP/ui5-builder#734 Enabled by Default Task Disabled -
generateBundle In case dependencies are bundled too Task Disabled Task Disabled -
generateLibraryPreload Dependency access removed with SAP/ui5-builder#734 - Enabled by Default -
generateStandaloneAppBundle Requires some dependency resources in order to create a self-contained bundle. Note: build --all is already recommended for self-contained builds in order to generate required theme resources which are not part of the standalone app bundle Task Disabled - -

As you can see, for projects of type application, there is no default task that requires access to dependencies. Therefore, application-projects can be built without building any dependencies.

Custom Tasks

Custom Tasks may or may not require dependencies. RFC 0012 UI5 Tooling Extension API v3, Chapter 3. Tasks Requiring Dependencies describes a concept, introduced in UI5 Tooling v3, which allows custom tasks to define which dependencies they require access to.

How we teach this

Drawbacks

Alternatives

Unresolved Questions and Bikeshedding

Currently none.