UI5 CLI v5 - Discuss Public Server API #1512
Replies: 1 comment 2 replies
|
My thoughts here:
Although the I would suggest that we add a comment to
I would question whether consumers of serveMiddleware really need the BuildServer interface, and rather keep it private (i.e. not return it), until both, our API contract is stable, and we know more about the use cases so we can make sure it fits. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
UI5 CLI v5 has seen some major refactoring of the
@ui5/serverpackage, which now watches the file system and builds projects incrementally, rather than serving raw sources with minor on-the-fly modification. This added a bunch of new modules and APIs to the package, some of which are relevant for consumers that interface directly with the package (rather than using the UI5 CLI command). Here we want to discuss which APIs should become public, in order to support common use cases.This is mainly intended for team internal discussions. But anyone who's interested, or has a relevant use case, is welcome to chime in.
AI generated overview of the current state of new APIs:
1.
graph.serve()has no@publicJSDocProjectGraph.serve()has no doc comment at all. The siblinggraph.build()directly above it is fully documented and@public, so it appears in the API Reference whileserve()does not.The documented Node.js examples call
graphFromPackageDependenciesand hand the graph to@ui5/server'sserve/serveMiddleware, so they don't go throughgraph.serve()directly. Butgraph.serve()returns theBuildServer(with its public reader methods), so if that is meant to be a supported entry point it needs a@publicdoc block with its options and return type.To be discussed: is
graph.serve()intended as public API, or is@ui5/serverthe only sanctioned entry point?2.
BuildServerclass has no JSDoc module/class headerBuildServercarries@publicon individual reader methods:getReader()getRootReader()getDependenciesReader()But the class itself has no
@public/@classheader, unlikeserver.jswhich declares@public @module @ui5/server. A consumer who obtains aBuildServer(fromgraph.serve()or from thebuildServerreturned byserveMiddleware) has no reference page for the class.Depends on the outcome of gap 1: if
graph.serve()and the returnedBuildServerare public, the class needs a documented header.3. Live re-resolution is not reachable through the public API
The
serve()signature acceptsgraphFactoryandprojectWatcher. Together they enable the "Project Definition Changes" behavior: watchui5.yaml/package.json/ workspace config /--config/--dependency-definition, re-resolve the graph, and re-create the serving stack behind the stable HTTP server.The CLI wires this up in
serve.js:projectWatchercomes from the internal subpath@ui5/project/internal/graph/ProjectDefinitionWatcher. An external consumer callingserve()without it gets a static server with no config-change re-resolution, so the definition-watching behavior only works viaui5 serve.The injection exists because
@ui5/serverdoes not depend on@ui5/project; the owner (the CLI) threads the watcher in. Options to discuss for making the capability reachable to embedders:ProjectDefinitionWatchersubpath to a public export, and document thegraphFactory+projectWatcherparams ofserve().@ui5/serverdepend on@ui5/projectdirectly and construct the watcher itself, dropping the injection.All reactions