What is @ui5/server?
@ui5/server is a development server for UI5 projects. It provides a local server environment to serve UI5 applications and libraries, enabling developers to test and debug their UI5 projects locally.
What are @ui5/server's main functionalities?
Serve UI5 Applications
This feature allows you to serve a UI5 application locally. The code sample demonstrates how to set up a server on port 8080 to serve resources from the './webapp' directory.
const { serve } = require('@ui5/server');
const server = serve({
port: 8080,
resources: {
path: './webapp'
}
});
server.start();
Middleware Support
This feature allows you to add custom middleware to the server. The code sample shows how to log the request URL using a custom middleware function.
const { serve } = require('@ui5/server');
const server = serve({
port: 8080,
resources: {
path: './webapp'
},
middleware: [
function customMiddleware(req, res, next) {
console.log('Request URL:', req.url);
next();
}
]
});
server.start();
Live Reload
This feature enables live reloading of the application when changes are detected. The code sample demonstrates how to enable live reload by setting the 'liveReload' option to true.
const { serve } = require('@ui5/server');
const server = serve({
port: 8080,
resources: {
path: './webapp'
},
liveReload: true
});
server.start();
Other packages similar to @ui5/server
http-server
http-server is a simple, zero-configuration command-line HTTP server. It can be used to serve static files and is often used for quick local development. Unlike @ui5/server, it does not have built-in support for UI5-specific features like middleware or live reload.
live-server
live-server is a simple development HTTP server with live reload capability. It automatically reloads the page when files change. While it provides live reload similar to @ui5/server, it lacks UI5-specific middleware support.
webpack-dev-server
webpack-dev-server is a development server that provides live reloading and other features for projects using Webpack. It is highly configurable and supports middleware, but it is more complex to set up compared to @ui5/server, which is tailored for UI5 projects.
[v3.0.0] - 2023-02-09
Breaking Changes
BREAKING CHANGE
This package has been transformed to ES Modules. Therefore it no longer provides a CommonJS export.
If your project uses CommonJS, it needs to be converted to ESM or use a dynamic import.
For more information see also:
- https://sap.github.io/ui5-tooling/updates/migrate-v3/
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
This removes the "/proxy" endpoint and the corresponding
"connectUi5Proxy" middleware from the standard ui5-server.
Internally, this middleware made use of the connect-openui5 proxy
implementation (https://github.com/SAP/connect-openui5#proxy).
More sophisticated proxy solutions for ui5-server are already available
in the form of custom middleware extensions from the UI5-community.
The UI5 Team might provide a dedicated custom middleware extension,
with similar functionality, in the future.
- Server now requires a Project Graph instance instead.
- Standard middleware now rely on Project instances being available on Resources (see https://github.com/SAP/ui5-fs/pull/381)
- MiddlewareRepository#addMiddleware has been removed. Custom middleware need to be added to the project graph instead
Support for older Node.js and npm releases has been dropped.
Only Node.js v16.18.0 and npm v8 or higher are supported.
Features
- MiddlewareUtil: Add getProject/getDependencies/resourceFactory API to interface (#547)
ab28f78
<a name="v2.4.1"></a>