packages/kbn-cli-dev-mode/README.mdx
This package exposes a function that manages the alternate behavior of the Kibana cli when using
the --dev flag. This mode provides several useful features in a single CLI for a nice developer
experience:
@kbn/optimizer to build browser bundlesTo accomplish this, and to make it easier to test, the CliDevMode class manages the following
objects.
WatcherThe Watcher manages a @parcel/watcher instance to watch the
server files, logs about file changes observed and provides an observable to the DevServer via
its serverShouldRestart$() method.
DevServerThe DevServer object is responsible for everything related to running and restarting the Kibana
server process:
Watcher object, sending SIGKILL to the existing
server and launching a new instance with the current codeOptimizerThe Optimizer object manages a @kbn/optimizer instance, adapting its configuration and
logging to the data available to the CLI.
BasePathProxyServerThis proxy injects a random three character base path in the URL that Kibana is served from to help ensure that Kibana features are written to adapt to custom base path configurations from users.
The basePathProxy also has another important job, ensuring that requests don't fail because the
server is restarting and that the browser receives front-end assets containing all saved
changes. We accomplish this by observing the ready state of the Optimizer and DevServer
objects and pausing all requests through the proxy until both objects report that they
aren't building/restarting based on recently saved changes.