UI5 Middleware: Serve Local Framework
raw JSON →This UI5 middleware, `ui5-middleware-serveframework`, integrates with the UI5 tooling to provide a local serving mechanism for the OpenUI5 or SAPUI5 framework. It automatically builds and caches the specified UI5 framework version (as defined in the project's `ui5.yaml`) into a local directory (`~/.ui5/ui5-middleware-serveframework` by default). Subsequent requests for the same UI5 version are then served directly from this local cache, significantly improving development server startup times and ensuring consistent, offline-capable environments by leveraging preload files and direct static file access. The current stable version, 3.7.1 (as of the last search results), indicates a healthy, community-driven project with regular updates. Its key differentiator is the ability to use a fully local, pre-built UI5 framework, offering benefits over relying on remote CDN sources or repeated on-the-fly compilation.
Common errors
error Error: ui5-middleware-serveframework: Could not find @ui5/cli version 3.x in project dependencies. ↓
@ui5/cli dependency to ^3.0.0 or higher in package.json and ensure ui5.yaml's specVersion is set to "3.0". error ERR_CERT_AUTHORITY_INVALID (or similar SSL certificate errors during framework build) ↓
strictSSL: false to the ui5-middleware-serveframework configuration in your ui5.yaml file to bypass SSL certificate validation for development purposes. error UI5 server starts, but UI5 resources (e.g., `sap/m/library.js`) are not found or return 404. ↓
ui5-middleware-serveframework is correctly listed under server.customMiddleware in ui5.yaml with afterMiddleware: compression. Ensure the framework section in ui5.yaml correctly specifies name and version (e.g., OpenUI5 and a valid version like 1.120.0), and that @ui5/builder and @ui5/project are present in devDependencies. Warnings
breaking All releases of `ui5-middleware-serveframework` with major version `3` require `@ui5/cli@3.0.0` or higher to function correctly. Using incompatible versions will lead to runtime errors during development server startup or framework building. ↓
gotcha By default, the middleware caches built UI5 framework libraries in the user's home directory (`~/.ui5/ui5-middleware-serveframework`). While this saves disk space by sharing caches across projects, it can lead to longer initial build times for each new UI5 version encountered. ↓
gotcha Incorrect `afterMiddleware` placement in your `ui5.yaml` can disrupt the middleware's functionality or interact negatively with other server components. The documentation recommends placing it after the `compression` middleware. ↓
gotcha If operating behind a corporate proxy with self-signed SSL certificates, the framework's build process might fail due to strict SSL checks when attempting to download UI5 resources. The `strictSSL` option defaults to `true`. ↓
gotcha There have been reported issues where `ui5-middleware-serveframework` can interfere with `ui5-test-runner`, causing tests to fail or run prematurely. ↓
Install
npm install ui5-middleware-serveframework yarn add ui5-middleware-serveframework pnpm add ui5-middleware-serveframework Imports
- Package Installation wrong
npm install ui5-middleware-serveframework (missing --save-dev for a typical development-only middleware)correctnpm install ui5-middleware-serveframework --save-dev - `package.json` devDependency entry wrong
Missing the dependency, or an incorrect version range causing compatibility issues.correct"devDependencies": { "ui5-middleware-serveframework": "^3.0.0" } - `ui5.yaml` Custom Middleware configuration wrong
Typo in the `name`, incorrect `afterMiddleware` placement, or misconfigured `configuration` options.correctserver: customMiddleware: - name: ui5-middleware-serveframework afterMiddleware: compression configuration: debug: true
Quickstart
// package.json (excerpt)
{
"name": "my-ui5-app",
"version": "1.0.0",
"private": true,
"description": "A minimal UI5 app using ui5-middleware-serveframework",
"devDependencies": {
"@ui5/cli": "^3.0.0",
"@ui5/builder": "^3.0.0",
"@ui5/project": "^3.0.0",
"ui5-middleware-serveframework": "^3.0.0"
},
"scripts": {
"start": "ui5 serve --config ui5.yaml"
}
}
// ui5.yaml (create this file in your project root)
# For documentation see: https://sap.github.io/ui5-tooling/pages/Configuration/
specVersion: "3.0"
metadata:
name: my.ui5.app
type: application
framework:
name: OpenUI5
version: "1.120.0" # Specify your desired UI5 version here
libraries:
- name: sap.m
- name: sap.ui.core
server:
customMiddleware:
- name: ui5-middleware-serveframework
afterMiddleware: compression
configuration:
debug: true
saveLibsLocal: true
# ui5VersionEnvVariable: UI5_VERSION # Uncomment to override version via env var
# strictSSL: false # Uncomment to disable strict SSL checks if behind a proxy