Skip to content

Commit 4b7e42c

Browse files
committed
docs(documentation): Update server chapter
1 parent 518b265 commit 4b7e42c

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

rfcs/0017-incremental-build.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ For each task, the following information is stored:
326326

327327
In this concept, each stage corresponds to the execution of a task. It contains the metadata for all resources **written** by the task during its execution. This is tracked via the provided workspace writer. The metadata includes the `lastModified`, `size` and `integrity` of each resource. This information is required for determining whether subsequent tasks need to be re-executed.
328328

329-
In the future, additional stages might be introduced. Therefore, stage names for tasks must be prefixed with `tasks/`.
329+
In the future, additional stages might be introduced. Therefore, stage names for tasks must be prefixed with `task/`.
330330

331331
#### Cache Directory Structure
332332

@@ -425,6 +425,18 @@ A dedicated command, such as `ui5 cache clean`, should be introduced in addition
425425

426426
The build API should provide a "watch" mode that will re-trigger the build when a source file is modified. The watch mode shall select the projects to watch based on which projects have been requested to be built. If a [UI5 CLI workspace](https://sap.github.io/ui5-tooling/stable/pages/Workspace/) is used, this can be fine-tuned in the workspace configuration.
427427

428+
The watch mode shall be used by the server to automatically rebuild projects when source files are modified and serve the updated resources. See below.
429+
430+
#### Cache Invalidation
431+
432+
Besides watching relevant source files, the watch mode shall also watch configuration files relevant for the build signature (e.g. ui5.yaml, package.json, tsconfig.json, etc.). If any of those files change, the cache needs to be replaced using the build signature.
433+
434+
#### Error Handling
435+
436+
If a task execution fails in watch mode, the error shall be logged but the watch mode shall stay active in anticipation of further changes. The process shall not crash or stop. This shall be a configuration option.
437+
438+
If some tasks have executed successfully before the error occurred, their results shall be kept in the cache and used for subsequent builds. Only the failed task and any downstream tasks shall be re-executed on the next build.
439+
428440
### Server Integration
429441

430442
The UI5 CLI server shall integrate the incremental build as a mean to pre-process projects before serving the build result. It shall use the watch mode to automatically rebuild the projects when source files are modified, so that always the latest resources are served.
@@ -439,6 +451,23 @@ While a build is running, the server shall pause responding to incoming requests
439451

440452
The server may implement "live-reload" functionality to inform client side code to refresh the page whenever changes have been detected and the build has finished.
441453

454+
#### Live Reload
455+
456+
The server may implement live-reload functionality to inform connected clients about changes in the build result. This can be achieved using WebSockets or Server-Sent Events (SSE).
457+
458+
This is an essential feature, since after saving an edited file, the user might not know when the build has finished and the changes are available in the browser. Although the server should also pause all incoming requests until the build has finished, an automatic refresh of the page improves the developer experience significantly.
459+
460+
For this purpose, a script is to be injected into the served HTML pages that establishes a connection to the server and listens for change notifications. Upon receiving a notification, the script should trigger a page reload to reflect the latest changes. The endpoint should be secured using a token-based mechanism to prevent unauthorized access.
461+
462+
## Integration in UI5 CLI
463+
464+
The following new arguments shall be added to the `ui5 build` and `ui5 serve` commands:
465+
466+
* `--no-cache`: Disables the use of the build cache entirely. The project will be built from scratch without leveraging any cached results.
467+
* **To be discussed:** This clashes with the currently existing [`--cache-mode` parameter](https://ui5.github.io/cli/stable/pages/CLI/#ui5-build). Should that one be renamed or repurposed?
468+
* `--watch`: Enables watch mode, causing the build to be re-triggered whenever a source file or relevant configuration file changes.
469+
* This parameter is only relevant for the `ui5 build` command. The `ui5 serve` command shall always use watch mode.
470+
442471
## How we teach this
443472

444473
This is a big change in the UI5 CLI architecture and especially impacts the way the UI5 CLI server works. By always building projects, developers might experience a slower startup time of the server. After modifying a file, it might also take longer until all processing is finished and the change is being served to the browser.
236 Bytes
Binary file not shown.
5.94 KB
Loading

0 commit comments

Comments
 (0)