-
Notifications
You must be signed in to change notification settings - Fork 80
docs: Add Incremental Build Vitepress docs #1404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,11 +286,37 @@ module.exports.determineRequiredDependencies = async function({availableDependen | |
| ``` | ||
| ::: | ||
|
|
||
| ### "Cache-aware" Tasks | ||
|
|
||
| Due to UI5 Builder and UI5 Server supporting **build caches** of task data, custom tasks can opt into this behavior to improve performance. This is done by implementing the following features: | ||
|
|
||
| #### `supportsDifferentialBuilds()` | ||
|
|
||
| This method indicates whether your task can perform differential builds: | ||
|
|
||
| ```js | ||
| /** | ||
| * Indicates whether this task can perform differential builds | ||
| * | ||
| * @returns {boolean} True if the task can process only modified resources | ||
| */ | ||
| export function supportsDifferentialBuilds() { | ||
| return true; | ||
| } | ||
| ``` | ||
|
|
||
| When this returns `true`, your task's main function receives an additional parameter indicating which resources have changed. The task can then process only those resources instead of all resources. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which additional parameter does the function receive? |
||
|
|
||
| ::: info Best Practices for Cache-aware Tasks | ||
| 1. **Keep tasks deterministic**: Given the same inputs, always produce the same outputs | ||
| 2. **Opt into differential builds carefully**: Only set `supportsDifferentialBuilds = true` if your task can safely process files independently | ||
| ::: | ||
|
|
||
| ### Examples | ||
|
|
||
| The following code snippets show examples for custom task implementations. | ||
|
|
||
| ### Example: lib/tasks/renderMarkdownFiles.js | ||
| #### Example: lib/tasks/renderMarkdownFiles.js | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about updating the example to show how to make use of |
||
|
|
||
| This example is making use of the `resourceFactory` [TaskUtil](https://ui5.github.io/cli/v5/api/@ui5_project_build_helpers_TaskUtil.html) | ||
| API to create new resources based on the output of a third-party module for rendering Markdown files. The created resources are added to the build | ||
|
|
@@ -364,7 +390,7 @@ Tasks should ideally use the reader/writer APIs provided by UI5 CLI for working | |
|
|
||
| ::: | ||
|
|
||
| ### Example: lib/tasks/compileLicenseSummary.js | ||
| #### Example: lib/tasks/compileLicenseSummary.js | ||
|
|
||
| This example is making use of multiple [TaskUtil](https://ui5.github.io/cli/v5/api/@ui5_project_build_helpers_TaskUtil.html) | ||
| APIs to retrieve additional information about the project currently being built (`taskUtil.getProject()`) and its direct dependencies | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,47 @@ UI5 CLI 5.x introduces **Specification Version 5.0**, which enables the new Comp | |
|
|
||
| Projects using older **Specification Versions** are expected to be **fully compatible with UI5 CLI v5**. | ||
|
|
||
| ## Build Cache | ||
|
|
||
| UI5 CLI v5 introduces **builds with caching** for both commands `ui5 build` and `ui5 serve`. This fundamental architectural change significantly improves build performance by reusing cached results from previous builds. | ||
|
|
||
| ### What Changed | ||
|
|
||
| **Previous Behavior (v4 and earlier):** | ||
| - Every source change resulted in an entire rebuild of all projects | ||
| - Every build re-executed all tasks | ||
| - No caching between builds or server sessions | ||
|
|
||
| **New Behavior (v5):** | ||
| - Only relevant projects are rebuilt | ||
| - Only modified resources and affected tasks are re-processed | ||
|
|
||
| ### Impact on Your Workflow | ||
|
|
||
| - **First build**: Probably slightly slower, as the cache is populated with all build outputs | ||
| - **Subsequent builds**: Significantly faster — only modified resources and affected tasks are reprocessed | ||
| - **Quick iterations**: Changes to individual files typically rebuild very quickly | ||
| - **Cross-session**: Caches are used between server restarts and build runs | ||
|
|
||
| ### For `ui5 build` | ||
|
|
||
| When `ui5 build` is executed, build caches are automatically serialized and reused when available. | ||
|
|
||
| ::: tip Tip for Single Builds (e.g. CI/CD) | ||
| If you plan to execute a build only once (e.g. during a CI run), consider using `--cache "Off"` (see [Build Cache Control](../pages/Builder.md#build-cache-control)) to skip cache serialization. | ||
| ::: | ||
|
|
||
| ### For `ui5 serve` | ||
|
|
||
| During a server session (started by `ui5 serve`), source changes are automatically being monitered. Then, if a request was made, the server detects this, tries to use caches and only rebuilds when none are available. For more information see [Watch Mode Behavior](../pages/Server.md#watch-mode-behavior). | ||
|
|
||
| ::: info Review custom middleware | ||
|
|
||
| With this feature, **build tasks are executed in server sessions**. For this reason, some custom middleware might be obsolete or cause problems. Projects utilizing such might need to adapt their configuration. | ||
|
|
||
| E.g. Middleware for browser live reloads is obsolete and can be removed. Also, middleware for Typescript transpilation is not required anymore (as long as the respective task is still set up). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ::: | ||
|
|
||
| ## Rename of Command Option | ||
|
|
||
| With UI5 CLI v5, the option `--cache-mode` (for commands `ui5 build` and `ui5 serve`) has been renamed to `--snapshot-cache`. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently true, but only because
buildandserveuse a different set of tasks (servepassesexcludedTasks: ["minify", "generateLibraryPreload", "generateComponentPreload", "generateBundle"]), so the existing cache is not re-used. If both use the same set of tasks, the cache is shared, as they both use the same build process under the hood.