You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/documentation/docs/pages/Builder.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,63 @@ For every type there is a set of default tasks. You can disable single tasks usi
14
14
<VPButtonclass="no-decoration"text="📚 API Reference"href="https://ui5.github.io/cli/v5/api/index.html"/>
15
15
</div>
16
16
17
+
## Incremental Build and Caching
18
+
19
+
Starting with UI5 CLI v5, UI5 project building integrates the **Incremental Build**. This architectural change brings significant benefits while introducing some behavioral differences compared to previous versions. Instead of rebuilding everything from scratch, the UI5 Builder tracks which resources have changed and which build tasks need to be re-executed:
20
+
21
+
### How It Works
22
+
23
+
When you start a project build with `ui5 build`:
24
+
25
+
1.**Cache Population and Reuse**: The UI5 CLI builds your project caching build results and metadata
26
+
1.**File Watching**: When Watch Mode is enabled, the CLI monitors your source files for changes and triggers automatic rebuilds (see [Watch Mode](#watch-mode) section)
27
+
1.**Incremental Rebuilds**: When a rebuild is triggered, only relevant tasks are re-executed and cached results from unrelated ones are used
28
+
1.**Cached Results**: Build outputs are cached to gain performance during subsequent builds
29
+
30
+
### Build Cache Control
31
+
32
+
You can control the build cache behavior using the `--cache` option:
33
+
34
+
-`--cache Default` (default): Use the cache if available, create it if missing
35
+
-`--cache Force`: Only use the cache; fail if the cache is unavailable or invalid
36
+
-`--cache ReadOnly`: Use existing cache but don't update it (useful for CI/CD)
37
+
-`--cache Off`: Disable caching entirely and always perform a full rebuild
38
+
39
+
Example:
40
+
```sh
41
+
ui5 build --cache Off
42
+
```
43
+
In this scenario, when a source file change is made, always perform a full rebuild (even if this source version already existed sometime ago).
44
+
45
+
::: warning Important
46
+
Build caches created by `ui5 build` and `ui5 serve` are **separate and cannot be mixed**. Each command maintains its own cache optimized for its specific use case.
47
+
:::
48
+
49
+
For more details on server caching, see the [UI5 Server documentation](./Server.md).
50
+
51
+
### Watch Mode
52
+
53
+
The `ui5 build` command supports a `--watch` flag that monitors source files for changes and automatically triggers incremental rebuilds:
54
+
55
+
```sh
56
+
ui5 build --watch
57
+
```
58
+
59
+
When watch mode is enabled:
60
+
- Source files in your project are monitored for changes
61
+
- Incremental rebuilds are triggered automatically when changes are detected
62
+
- Only affected tasks are re-executed
63
+
64
+
::: tip
65
+
Watch mode monitors your source files only. Changes to configuration files (`ui5.yaml`, `package.json`) or custom task implementations require restarting the build command.
66
+
:::
67
+
68
+
::: info Info
69
+
For `ui5 serve`, this behavior is always turned on automatically.
70
+
:::
71
+
72
+
TODO: check this section again once it's implemented
73
+
17
74
## Tasks
18
75
Tasks are specific build steps to be executed during build phase.
Copy file name to clipboardExpand all lines: internal/documentation/docs/pages/Overview.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,20 @@ When developing a UI5 project on your local system, you should use the UI5 Serve
3
3
4
4
However, you might have good reasons to also use the UI5 Builder during development. In such cases, feel free to let us know! Maybe your use case could be covered by a future enhancement of the UI5 Server.
5
5
6
+
## Incremental Build and Caching
7
+
8
+
Starting with UI5 CLI v5, both `ui5 serve` and `ui5 build` use the **Incremental Build** to improve performance:
9
+
10
+
- Build results are cached and reused across builds and server sessions
11
+
- Only modified resources and affected build tasks are reprocessed
12
+
- The server automatically watches source files and triggers rebuilds when changes are detected
13
+
- Custom build tasks from dependencies execute automatically — no manual middleware configuration needed
14
+
15
+
For more details, see:
16
+
-[UI5 Server: Incremental Build and Caching](./Server.md#incremental-build-and-caching)
17
+
-[UI5 Builder: Incremental Build and Caching](./Builder.md#incremental-build-and-caching)
Copy file name to clipboardExpand all lines: internal/documentation/docs/pages/Server.md
+66Lines changed: 66 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,66 @@ Please be aware of the following risks when using the server:
23
23
24
24
:::
25
25
26
+
27
+
## Development Server
28
+
29
+
Starting with UI5 CLI v5, the development server integrates with the **Incremental Build**. This architectural change brings significant benefits while introducing some behavioral differences compared to previous versions.
30
+
31
+
### How It Works
32
+
33
+
When you start the server with `ui5 serve`:
34
+
35
+
1.**On-Demand Building**: The server builds your project only when a request comes in, and only if no cache exists or the cache is stale
36
+
1.**File Watching**: The server monitors your source files for changes
37
+
1.**Incremental Rebuilds**: When changes are detected and a new request is sent, an automatic rebuild is triggered containing only relevant build tasks
38
+
1.**Live Reload**: If live reload is enabled, the browser automatically refreshes once a rebuild completes (see [Live Reload](#live-reload) section)
39
+
1.**Cached Results**: Build outputs are cached to gain performance during subsequent builds
40
+
41
+
### Benefits
42
+
43
+
-**Faster Subsequent Builds**: The incremental build cache significantly speeds up rebuilds after the first run
44
+
-**Automatic Dependency Task Execution**: Custom build tasks defined in your project's dependencies (libraries, modules) are now executed automatically during the build. You no longer need to configure custom middleware to handle these tasks.
45
+
-**Theme Pre-Compilation**: Themes are now pre-compiled by the `buildThemes` task during the build, improving performance (see [Removed Middleware](#standard-middleware) section)
46
+
47
+
### Server Cache Control
48
+
49
+
You can control the build cache behavior using the `--cache` option:
50
+
51
+
-`--cache Default` (default): Use the cache if available, create it if missing
52
+
-`--cache Force`: Only use the cache; fail if the cache is unavailable or invalid
53
+
-`--cache ReadOnly`: Use existing cache but don't update it (useful for CI/CD)
54
+
-`--cache Off`: Disable caching entirely and always perform a full rebuild
55
+
56
+
Example:
57
+
```sh
58
+
ui5 serve --cache Off
59
+
```
60
+
In this scenario, when a source file change is made and a request comes in, always perform a full rebuild (even if this source version already existed sometime ago).
61
+
62
+
::: warning Important
63
+
Build caches created by `ui5 build` and `ui5 serve` are **separate and cannot be mixed**. Each command maintains its own cache optimized for its specific use case.
64
+
:::
65
+
66
+
For more details on build caching, see the [UI5 Builder documentation](./Builder.md).
67
+
68
+
### Watch Mode Behavior
69
+
70
+
The server automatically watches your source files and triggers rebuilds when changes are detected:
71
+
72
+
-**Monitored files**: All files in your project's source directories (`src/`, `webapp/`, `test/`, etc.)
Changes to configuration files or custom tasks require a server restart to take effect.
77
+
:::
78
+
79
+
### Live Reload
80
+
81
+
When Live Reload is enabled, the server automatically triggers a rebuild (utilizing caches) and notifies connected browsers to automatically refresh the page. This feature requires:
82
+
83
+
TODO: Add explanation once live reload is implemented (CLI option + yaml config)
84
+
TODO: Mention that this supersedes ui5-livereload-middleware
85
+
26
86
## Standard Middleware
27
87
28
88
::: info Removed Middleware
@@ -87,6 +147,12 @@ Answers all non-read requests (POST, PUT, DELETE, etc.) that have not been answe
87
147
### serveIndex
88
148
In case a directory has been requested, this middleware renders an HTML with a list of the directory's content.
89
149
150
+
## Standard Tasks
151
+
With UI5 CLI v5, a set of Standard Tasks is executed during a server build...
TODO: Add list/table of standard tasks for ui5 serve (similar to Builder docs) with reference to the API docs (for more info)
154
+
TODO: Add --exclude-task explanation once and whether it's merged: "You may exclude unnecessary tasks to speed up development even more: ui5 serve --exclude-task enhanceManifest
155
+
90
156
## SSL Certificates
91
157
When starting the UI5 Server in HTTPS- or HTTP/2 mode, for example by using UI5 CLI parameter `--h2`, you will be prompted for the automatic generation of a local SSL certificate if necessary.
Copy file name to clipboardExpand all lines: internal/documentation/docs/pages/extensibility/CustomServerMiddleware.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,33 @@ There can be optional configuration parameters which are passed directly to the
34
34
35
35
An optional mountPath for which the middleware function is invoked can be provided. It will be passed to the `app.use` call (see [express API reference](https://expressjs.com/en/4x/api.html#app.use)).
36
36
37
+
### With Incremental Build
38
+
39
+
**Change in UI5 CLI v5:** The development server now integrates with the incremental build system. When a request comes in, the server builds the project on-demand (if no cache exists or the cache is stale) before serving resources.
40
+
41
+
- **Custom build tasks from dependencies execute automatically**: If your reusable library or module defines custom build tasks, they will be executed during the build phase. You no longer need to configure custom middleware at the root project level to handle tasks from dependencies.
42
+
43
+
- **Middleware receives pre-built resources**: The `resources` parameter passed to your middleware implementation provides access to fully built resources, including outputs from all build tasks (both standard and custom).
44
+
45
+
#### Accessing Build Outputs in Middleware
46
+
47
+
The `resources` readers provided to your middleware return pre-built resources:
48
+
49
+
```js
50
+
export default function({resources, log}) {
51
+
return async function (req, res, next) {
52
+
// This returns the built resource, including all task transformations
// The content has already been processed by all build tasks
58
+
}
59
+
next();
60
+
}
61
+
}
62
+
```
63
+
37
64
### Execution order
38
65
39
66
Note that middleware configurations are applied in the order they are defined. When referencing another custom middleware, it has to be defined *before* that reference.
Copy file name to clipboardExpand all lines: internal/documentation/docs/pages/extensibility/CustomTasks.md
+102Lines changed: 102 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,108 @@ task:
103
103
path: lib/tasks/renderMarkdownFiles.js
104
104
```
105
105
106
+
## Incremental Build Support
107
+
108
+
Starting with UI5 CLI v5, the UI5 Builder supports **incremental builds** by caching task data. Custom tasks can opt into this behavior to improve performance.
109
+
110
+
### How Incremental Builds Work for Tasks
111
+
112
+
1. **First Execution**: The task runs normally and its outputs are cached
113
+
1. **Resource Tracking**: The build system tracks which resources the task reads and writes
114
+
1. **Cache Validation**: On subsequent builds, if the task's inputs haven't changed, the cached outputs are reused and the task is skipped
115
+
1. **Incremental Execution**: If only some inputs changed, the task can optionally process only those changed resources (see [supportsDifferentialBuilds()](#supportsDifferentialBuilds()) below)
116
+
117
+
### Making Your Task Cache-Aware (Differential Builds)
118
+
119
+
Custom build tasks can now optionally support **differential builds** by implementing the following new features.
120
+
121
+
::: info Info
122
+
When a task supports differential builds, it is the task author's responsibility to ensure correctness. Specifically, if a task's output for resource A depends on the content of resource B, the task must account for this when processing only the changed resources. Tasks that cannot reliably determine such cross-resource dependencies should not enable differential build support. For example, bundling tasks — where the output depends on the content of many input resources — may not support differential builds until a more robust solution is available.
123
+
:::
124
+
125
+
#### `supportsDifferentialBuilds()`
126
+
127
+
TODO: Check this section again
128
+
129
+
Indicates whether your task can process only changed resources:
130
+
131
+
```js
132
+
/**
133
+
* Indicates whether this task can perform differential builds
134
+
*
135
+
* @returns {boolean} True if the task can process only modified resources
136
+
*/
137
+
export function supportsDifferentialBuilds() {
138
+
return true; // This task can process only changed files
139
+
}
140
+
```
141
+
142
+
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.
143
+
144
+
#### `determineBuildSignature({log, options})`
145
+
146
+
TODO: Check this section again
147
+
148
+
Returns `undefined` or an arbitrary string representing the build signature for the task. This can be used to incorporate task-specific configuration files into the build signature of the project, causing the cache to be invalidated if those files change. The string should not be a hash value (the build signature hash is calculated later). If `undefined` is returned, or if the method is not implemented, it is assumed that the task's cache remains valid until relevant input resources change.
149
+
150
+
This method is called once at the beginning of every build. The return value is used to calculate a unique signature for the task based on its configuration. This signature is then incorporated into the overall build signature of the project.
151
+
152
+
```js
153
+
/**
154
+
* Determines the build signature for this task
155
+
*
156
+
* Configuration changes that affect output should be reflected in this signature
export async function determineBuildSignature({log, options}) {
164
+
return "TODO:";
165
+
}
166
+
```
167
+
168
+
**Example use case:** A TypeScript compilation task that includes the TypeScript version and `tsconfig.json` settings in its signature, so the cache is invalidated when compiler settings change.
Declares which resources the task is expected to produce. This allows the build system to detect and remove stale outputs when the task stops producing files it previously created.
175
+
176
+
This method is called right before the task is being executed. It is used to detect stale output resources that were produced in a previous execution of the task, but are no longer produced in the current execution. Such stale resources must be removed from the build output to avoid inconsistencies.
177
+
178
+
```js
179
+
/**
180
+
* Determines which resources this task is expected to produce
181
+
*
182
+
* @param {object} parameters
183
+
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace Reader/Writer for project resources
184
+
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader for dependency resources
**Example use case:** A code generator that creates JavaScript files from TypeScript sources. If a `.ts` file is deleted, the corresponding `.js` file should also be removed.
199
+
200
+
### Best Practices for Cache-Aware Tasks
201
+
202
+
1. **Keep tasks deterministic**: Given the same inputs, always produce the same outputs
203
+
2. **Use `determineBuildSignature`**: Include all configuration that affects output in the build signature
204
+
3. **Opt into differential builds carefully**: Only set `supportsDifferentialBuilds = true` if your task can safely process files independently
205
+
4. **Declare expected outputs**: Implement `determineExpectedOutput` if your task generates new files (not just modifies existing ones)
206
+
5. **Test cache behavior**: Verify that your task produces identical results whether running from cache or fresh execution
207
+
106
208
## Task Implementation
107
209
108
210
A custom task implementation needs to return a function with the following signature:
0 commit comments