From 9b0e13a92506a6d2cf027d1ab2055cf32cf8a616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Wed, 8 Nov 2023 13:43:01 +0100 Subject: [PATCH 01/12] async-import plugins in the server side --- examples/bfetch_explorer/server/index.ts | 7 ++- .../server/index.ts | 4 +- examples/embeddable_examples/server/index.ts | 7 ++- .../feature_control_examples/server/index.ts | 6 +- .../field_formats_example/server/index.ts | 5 +- examples/files_example/server/index.ts | 4 +- .../guided_onboarding_example/server/index.ts | 6 +- examples/preboot_example/server/index.ts | 6 +- examples/response_stream/server/index.ts | 5 +- examples/routing_example/server/index.ts | 7 ++- .../screenshot_mode_example/server/index.ts | 6 +- examples/search_examples/server/index.ts | 4 +- .../user_profile_examples/server/index.ts | 6 +- examples/v8_profiler_examples/server/index.ts | 4 +- .../src/plugin_initializer.ts | 4 +- .../src/plugin.ts | 12 +++- .../src/plugins_system.ts | 1 + .../plugins/core-plugins-server/src/types.ts | 5 +- src/plugins/advanced_settings/server/index.ts | 7 ++- src/plugins/bfetch/server/index.ts | 4 +- .../expression_gauge/server/index.ts | 5 +- .../expression_heatmap/server/index.ts | 5 +- .../expression_legacy_metric/server/index.ts | 5 +- .../expression_metric/server/index.ts | 5 +- .../expression_partition_vis/server/index.ts | 5 +- .../expression_tagcloud/server/index.ts | 5 +- .../expression_xy/server/index.ts | 5 +- src/plugins/charts/server/index.ts | 6 +- src/plugins/console/server/index.ts | 8 ++- .../content_management/server/index.ts | 5 +- src/plugins/controls/server/index.ts | 7 ++- .../custom_integrations/server/index.ts | 4 +- src/plugins/dashboard/server/index.ts | 4 +- src/plugins/data/server/index.ts | 7 ++- .../data_view_field_editor/server/index.ts | 4 +- .../data_view_management/server/index.ts | 4 +- src/plugins/data_views/server/index.ts | 7 ++- src/plugins/dev_tools/server/index.ts | 7 ++- src/plugins/discover/server/index.ts | 6 +- src/plugins/embeddable/server/index.ts | 7 ++- src/plugins/es_ui_shared/server/index.ts | 2 +- src/plugins/event_annotation/server/index.ts | 7 ++- src/plugins/expression_image/server/index.ts | 5 +- src/plugins/expression_metric/server/index.ts | 5 +- .../expression_repeat_image/server/index.ts | 5 +- .../expression_reveal_image/server/index.ts | 5 +- src/plugins/expression_shape/server/index.ts | 5 +- src/plugins/expressions/server/index.ts | 5 +- src/plugins/field_formats/server/index.ts | 4 +- src/plugins/files/server/index.ts | 4 +- src/plugins/ftr_apis/server/index.ts | 4 +- src/plugins/guided_onboarding/server/index.ts | 4 +- src/plugins/home/server/index.ts | 6 +- src/plugins/input_control_vis/server/index.ts | 4 +- src/plugins/interactive_setup/server/index.ts | 8 ++- .../kibana_usage_collection/server/index.ts | 4 +- src/plugins/links/server/index.ts | 6 +- src/plugins/management/server/index.ts | 7 ++- src/plugins/maps_ems/server/index.ts | 60 ++----------------- src/plugins/maps_ems/server/plugin.ts | 56 +++++++++++++++++ src/plugins/newsfeed/server/index.ts | 4 +- src/plugins/presentation_util/server/index.ts | 7 ++- src/plugins/saved_objects/public/index.ts | 2 +- .../saved_objects_finder/server/index.ts | 7 ++- .../saved_objects_management/server/index.ts | 7 ++- src/plugins/saved_search/server/index.ts | 7 ++- src/plugins/screenshot_mode/server/index.ts | 5 +- src/plugins/share/server/index.ts | 4 +- src/plugins/telemetry/server/index.ts | 7 ++- .../server/index.ts | 4 +- .../ui_actions_enhanced/server/index.ts | 7 +-- src/plugins/unified_search/server/index.ts | 7 ++- src/plugins/usage_collection/server/index.ts | 7 ++- src/plugins/vis_type_markdown/server/index.ts | 2 +- src/plugins/vis_types/gauge/server/index.ts | 7 ++- src/plugins/vis_types/heatmap/server/index.ts | 7 ++- src/plugins/vis_types/metric/server/index.ts | 2 +- src/plugins/vis_types/pie/server/index.ts | 7 ++- .../vis_types/timelion/server/index.ts | 7 ++- .../vis_types/timeseries/server/index.ts | 4 +- src/plugins/vis_types/vega/server/index.ts | 4 +- src/plugins/vis_types/vislib/server/index.ts | 6 +- src/plugins/vis_types/xy/server/index.ts | 7 ++- src/plugins/visualizations/server/index.ts | 4 +- .../analytics_ftr_helpers/server/index.ts | 2 +- .../analytics_plugin_a/server/index.ts | 2 +- test/common/plugins/newsfeed/server/index.ts | 2 +- .../plugins/otel_metrics/server/index.ts | 2 +- .../plugins/status/server/index.ts | 2 +- .../plugins/test_endpoints/server/index.ts | 4 +- .../kbn_tp_run_pipeline/server/index.ts | 3 +- .../server/index.ts | 2 +- .../core_dynamic_resolving_a/server/index.ts | 2 +- .../core_dynamic_resolving_b/server/index.ts | 2 +- .../plugins/core_http/server/index.ts | 2 +- .../plugins/core_plugin_a/server/index.ts | 2 +- .../plugins/core_plugin_b/server/index.ts | 2 +- .../core_plugin_deprecations/server/index.ts | 2 +- .../server/index.ts | 2 +- .../server/index.ts | 2 +- .../plugins/data_search/server/index.ts | 2 +- .../server/index.ts | 2 +- .../plugins/index_patterns/server/index.ts | 2 +- .../plugins/rendering_plugin/server/index.ts | 2 +- .../server/index.ts | 2 +- .../server/index.ts | 2 +- .../server/index.ts | 2 +- .../saved_objects_hidden_type/server/index.ts | 2 +- .../ui_settings_plugin/server/index.ts | 2 +- .../plugins/usage_collection/server/index.ts | 2 +- .../plugins/status_plugin_a/server/index.ts | 2 +- .../plugins/status_plugin_b/server/index.ts | 2 +- x-pack/plugins/actions/server/index.ts | 6 +- x-pack/plugins/aiops/server/index.ts | 4 +- x-pack/plugins/alerting/server/index.ts | 6 +- x-pack/plugins/apm/server/index.ts | 7 ++- .../plugins/apm_data_access/server/index.ts | 4 +- x-pack/plugins/asset_manager/server/index.ts | 13 ++-- x-pack/plugins/banners/server/index.ts | 6 +- x-pack/plugins/canvas/server/index.ts | 7 ++- x-pack/plugins/cases/server/index.ts | 7 ++- x-pack/plugins/cloud/server/index.ts | 4 +- x-pack/plugins/cloud_defend/server/index.ts | 4 +- .../cloud_chat/server/index.ts | 4 +- .../cloud_data_migration/server/index.ts | 7 ++- .../cloud_experiments/server/index.ts | 4 +- .../cloud_full_story/server/index.ts | 4 +- .../cloud_gain_sight/server/index.ts | 4 +- .../cloud_security_posture/server/index.ts | 7 ++- .../cross_cluster_replication/server/index.ts | 7 ++- .../plugins/custom_branding/server/index.ts | 5 +- .../dashboard_enhanced/server/index.ts | 4 +- .../plugins/data_visualizer/server/index.ts | 6 +- .../plugins/discover_enhanced/server/index.ts | 6 +- .../server/index.ts | 4 +- .../plugins/elastic_assistant/server/index.ts | 4 +- .../encrypted_saved_objects/server/index.ts | 7 ++- .../plugins/enterprise_search/server/index.ts | 5 +- x-pack/plugins/event_log/server/index.ts | 6 +- x-pack/plugins/features/server/index.ts | 7 ++- x-pack/plugins/file_upload/server/index.ts | 7 ++- x-pack/plugins/fleet/server/index.ts | 5 +- x-pack/plugins/global_search/server/index.ts | 11 ++-- .../global_search_providers/server/index.ts | 13 +++- x-pack/plugins/graph/server/index.ts | 7 ++- x-pack/plugins/grokdebugger/server/index.js | 5 +- .../server/index.ts | 7 ++- .../plugins/index_management/server/index.ts | 7 ++- x-pack/plugins/infra/server/index.ts | 5 +- .../plugins/ingest_pipelines/server/index.ts | 5 +- .../kubernetes_security/server/index.ts | 4 +- x-pack/plugins/lens/server/index.ts | 6 +- .../license_management/server/index.ts | 7 ++- x-pack/plugins/licensing/server/index.ts | 6 +- x-pack/plugins/lists/server/index.ts | 10 ++-- x-pack/plugins/log_explorer/server/index.ts | 7 ++- x-pack/plugins/logs_shared/server/index.ts | 4 +- x-pack/plugins/logstash/server/index.ts | 6 +- x-pack/plugins/maps/server/index.ts | 7 ++- .../metrics_data_access/server/index.ts | 4 +- x-pack/plugins/ml/server/index.ts | 6 +- x-pack/plugins/monitoring/server/index.ts | 6 +- .../monitoring_collection/server/index.ts | 7 ++- x-pack/plugins/notifications/server/index.ts | 4 +- x-pack/plugins/observability/server/index.ts | 8 ++- .../server/index.ts | 7 ++- .../server/index.ts | 7 ++- .../observability_onboarding/server/index.ts | 4 +- x-pack/plugins/osquery/server/index.ts | 5 +- x-pack/plugins/painless_lab/server/index.ts | 4 +- x-pack/plugins/profiling/server/index.ts | 4 +- .../profiling_data_access/server/index.ts | 4 +- .../plugins/remote_clusters/server/index.ts | 6 +- x-pack/plugins/reporting/server/index.ts | 7 ++- x-pack/plugins/rollup/server/index.ts | 7 ++- x-pack/plugins/rule_registry/server/index.ts | 7 ++- .../saved_objects_tagging/server/index.ts | 7 ++- x-pack/plugins/screenshotting/server/index.ts | 5 +- x-pack/plugins/searchprofiler/server/index.ts | 4 +- x-pack/plugins/security/server/index.ts | 6 +- .../plugins/security_solution/server/index.ts | 6 +- .../security_solution_ess/server/index.ts | 4 +- .../server/index.ts | 4 +- x-pack/plugins/serverless/server/index.ts | 4 +- .../serverless_observability/server/index.ts | 4 +- .../plugins/serverless_search/public/index.ts | 5 +- x-pack/plugins/session_view/server/index.ts | 4 +- .../plugins/snapshot_restore/server/index.ts | 6 +- x-pack/plugins/spaces/server/index.ts | 7 ++- x-pack/plugins/stack_alerts/server/index.ts | 6 +- .../plugins/stack_connectors/server/index.ts | 7 ++- x-pack/plugins/synthetics/server/index.ts | 8 +-- x-pack/plugins/task_manager/server/index.ts | 6 +- .../server/index.ts | 5 +- .../threat_intelligence/server/index.ts | 4 +- x-pack/plugins/timelines/server/index.ts | 4 +- x-pack/plugins/transform/server/index.ts | 7 ++- x-pack/plugins/translations/server/index.ts | 2 +- .../triggers_actions_ui/server/index.ts | 6 +- .../plugins/upgrade_assistant/server/index.ts | 4 +- x-pack/plugins/uptime/server/index.ts | 7 ++- x-pack/plugins/ux/server/index.ts | 7 ++- x-pack/plugins/watcher/server/index.ts | 7 ++- .../common/plugins/aad/server/index.ts | 2 +- .../actions_simulators/server/index.ts | 2 +- .../common/plugins/alerts/server/index.ts | 3 +- .../plugins/alerts_restricted/server/index.ts | 2 +- .../task_manager_fixture/server/index.ts | 2 +- .../common/plugins/cases/server/index.ts | 2 +- .../plugins/observability/server/index.ts | 2 +- .../plugins/security_solution/server/index.ts | 2 +- .../plugins/saml_provider/server/index.ts | 2 +- .../api_consumer_plugin/server/index.ts | 2 +- .../plugins/kibana_cors_test/server/index.ts | 3 +- .../plugins/iframe_embedded/server/index.ts | 2 +- .../plugins/alerts/server/index.ts | 2 +- .../plugins/alerts/server/index.ts | 2 +- .../plugins/cases/server/index.ts | 2 +- .../elasticsearch_client/server/index.ts | 2 +- .../plugins/event_log/server/index.ts | 2 +- .../feature_usage_test/server/index.ts | 2 +- .../sample_task_plugin/server/index.ts | 2 +- .../task_manager_performance/server/index.ts | 2 +- .../saved_object_test_plugin/server/index.ts | 2 +- .../plugins/audit_log/server/index.ts | 2 +- .../plugins/oidc_provider/server/index.ts | 2 +- .../plugins/saml_provider/server/index.ts | 2 +- .../user_profiles_consumer/server/index.ts | 7 +-- .../plugins/test_endpoints/server/index.ts | 4 +- .../spaces_test_plugin/server/index.ts | 2 +- .../common/plugins/foo_plugin/server/index.ts | 2 +- 231 files changed, 667 insertions(+), 547 deletions(-) create mode 100644 src/plugins/maps_ems/server/plugin.ts diff --git a/examples/bfetch_explorer/server/index.ts b/examples/bfetch_explorer/server/index.ts index 4dd6223251dc3..6f80829362d6b 100644 --- a/examples/bfetch_explorer/server/index.ts +++ b/examples/bfetch_explorer/server/index.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ -import { BfetchExplorerPlugin } from './plugin'; - -export const plugin = () => new BfetchExplorerPlugin(); +export const plugin = async () => { + const { BfetchExplorerPlugin } = await import('./plugin'); + return new BfetchExplorerPlugin(); +}; diff --git a/examples/content_management_examples/server/index.ts b/examples/content_management_examples/server/index.ts index d75af7bacf224..069a36852fca7 100644 --- a/examples/content_management_examples/server/index.ts +++ b/examples/content_management_examples/server/index.ts @@ -7,8 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ContentManagementExamplesPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ContentManagementExamplesPlugin } = await import('./plugin'); return new ContentManagementExamplesPlugin(initializerContext); } diff --git a/examples/embeddable_examples/server/index.ts b/examples/embeddable_examples/server/index.ts index 0139633a71d69..cb0e20e34042e 100644 --- a/examples/embeddable_examples/server/index.ts +++ b/examples/embeddable_examples/server/index.ts @@ -8,6 +8,7 @@ import { PluginInitializer } from '@kbn/core/server'; -import { EmbeddableExamplesPlugin } from './plugin'; - -export const plugin: PluginInitializer = () => new EmbeddableExamplesPlugin(); +export const plugin: PluginInitializer = async () => { + const { EmbeddableExamplesPlugin } = await import('./plugin'); + return new EmbeddableExamplesPlugin(); +}; diff --git a/examples/feature_control_examples/server/index.ts b/examples/feature_control_examples/server/index.ts index 0db874ff2047e..20cf4e280ca45 100644 --- a/examples/feature_control_examples/server/index.ts +++ b/examples/feature_control_examples/server/index.ts @@ -6,6 +6,8 @@ * Side Public License, v 1. */ import { PluginInitializer } from '@kbn/core/server'; -import { FeatureControlsPluginExample } from './plugin'; -export const plugin: PluginInitializer = () => new FeatureControlsPluginExample(); +export const plugin: PluginInitializer = async () => { + const { FeatureControlsPluginExample } = await import('./plugin'); + return new FeatureControlsPluginExample(); +}; diff --git a/examples/field_formats_example/server/index.ts b/examples/field_formats_example/server/index.ts index cd8ee4c30b63a..63537dc1393fe 100644 --- a/examples/field_formats_example/server/index.ts +++ b/examples/field_formats_example/server/index.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ -import { FieldFormatsExamplePlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { FieldFormatsExamplePlugin } = await import('./plugin'); return new FieldFormatsExamplePlugin(); } diff --git a/examples/files_example/server/index.ts b/examples/files_example/server/index.ts index d7edefbe1876d..0ca8a663aa7f5 100644 --- a/examples/files_example/server/index.ts +++ b/examples/files_example/server/index.ts @@ -7,11 +7,11 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { FilesExamplePlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { FilesExamplePlugin } = await import('./plugin'); return new FilesExamplePlugin(initializerContext); } diff --git a/examples/guided_onboarding_example/server/index.ts b/examples/guided_onboarding_example/server/index.ts index dbcdfe70c67ee..a70d488d29236 100644 --- a/examples/guided_onboarding_example/server/index.ts +++ b/examples/guided_onboarding_example/server/index.ts @@ -7,6 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { GuidedOnboardingExamplePlugin } from './plugin'; -export const plugin = (ctx: PluginInitializerContext) => new GuidedOnboardingExamplePlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { GuidedOnboardingExamplePlugin } = await import('./plugin'); + return new GuidedOnboardingExamplePlugin(ctx); +}; diff --git a/examples/preboot_example/server/index.ts b/examples/preboot_example/server/index.ts index cc231e0c873ed..b5442168f99ab 100644 --- a/examples/preboot_example/server/index.ts +++ b/examples/preboot_example/server/index.ts @@ -10,11 +10,13 @@ import type { TypeOf } from '@kbn/config-schema'; import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { ConfigSchema } from './config'; -import { PrebootExamplePlugin } from './plugin'; export const config: PluginConfigDescriptor> = { schema: ConfigSchema, exposeToBrowser: { token: true }, }; -export const plugin = (context: PluginInitializerContext) => new PrebootExamplePlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { PrebootExamplePlugin } = await import('./plugin'); + return new PrebootExamplePlugin(context); +}; diff --git a/examples/response_stream/server/index.ts b/examples/response_stream/server/index.ts index 2d1bb6229fce4..9f6fd17f56ae1 100644 --- a/examples/response_stream/server/index.ts +++ b/examples/response_stream/server/index.ts @@ -8,8 +8,7 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { ResponseStreamPlugin } from './plugin'; - -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ResponseStreamPlugin } = await import('./plugin'); return new ResponseStreamPlugin(initializerContext); } diff --git a/examples/routing_example/server/index.ts b/examples/routing_example/server/index.ts index 1fc65c6da1314..fd5a8f2680c0d 100644 --- a/examples/routing_example/server/index.ts +++ b/examples/routing_example/server/index.ts @@ -8,6 +8,7 @@ import { PluginInitializer } from '@kbn/core/server'; -import { RoutingExamplePlugin } from './plugin'; - -export const plugin: PluginInitializer<{}, {}> = () => new RoutingExamplePlugin(); +export const plugin: PluginInitializer<{}, {}> = async () => { + const { RoutingExamplePlugin } = await import('./plugin'); + return new RoutingExamplePlugin(); +}; diff --git a/examples/screenshot_mode_example/server/index.ts b/examples/screenshot_mode_example/server/index.ts index 3237dbabff937..e383939cf7281 100644 --- a/examples/screenshot_mode_example/server/index.ts +++ b/examples/screenshot_mode_example/server/index.ts @@ -7,6 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ScreenshotModeExamplePlugin } from './plugin'; -export const plugin = (ctx: PluginInitializerContext) => new ScreenshotModeExamplePlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { ScreenshotModeExamplePlugin } = await import('./plugin'); + return new ScreenshotModeExamplePlugin(ctx); +}; diff --git a/examples/search_examples/server/index.ts b/examples/search_examples/server/index.ts index 1b1f69bcb32aa..211bdb658b590 100644 --- a/examples/search_examples/server/index.ts +++ b/examples/search_examples/server/index.ts @@ -7,9 +7,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SearchExamplesPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { SearchExamplesPlugin } = await import('./plugin'); return new SearchExamplesPlugin(initializerContext); } diff --git a/examples/user_profile_examples/server/index.ts b/examples/user_profile_examples/server/index.ts index 7b5e8eb32a645..6929bd5c6bb0e 100755 --- a/examples/user_profile_examples/server/index.ts +++ b/examples/user_profile_examples/server/index.ts @@ -5,6 +5,8 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { UserProfilesPlugin } from './plugin'; -export const plugin = () => new UserProfilesPlugin(); +export const plugin = async () => { + const { UserProfilesPlugin } = await import('./plugin'); + return new UserProfilesPlugin(); +}; diff --git a/examples/v8_profiler_examples/server/index.ts b/examples/v8_profiler_examples/server/index.ts index d06809f7411b5..f917a93ebd5f1 100644 --- a/examples/v8_profiler_examples/server/index.ts +++ b/examples/v8_profiler_examples/server/index.ts @@ -7,8 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { V8ProfilerExamplesPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { V8ProfilerExamplesPlugin } = await import('./plugin'); return new V8ProfilerExamplesPlugin(initializerContext); } diff --git a/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts b/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts index c33abbfc386f9..8f672c7213c32 100644 --- a/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts +++ b/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts @@ -22,7 +22,9 @@ export type PluginInitializer< TStart, TPluginsSetup extends object = object, TPluginsStart extends object = object -> = (core: PluginInitializerContext) => Plugin; +> = ( + core: PluginInitializerContext +) => Promise>; /** * The available core services passed to a `PluginInitializer` diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugin.ts b/packages/core/plugins/core-plugins-server-internal/src/plugin.ts index 3a8015aad4d59..7877886198cf5 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugin.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugin.ts @@ -87,6 +87,10 @@ export class PluginWrapper< this.includesUiPlugin = params.manifest.ui; } + public async init() { + this.instance = await this.createPluginInstance(); + } + /** * Instantiates plugin and calls `setup` function exposed by the plugin initializer. * @param setupContext Context that consists of various core services tailored specifically @@ -98,7 +102,9 @@ export class PluginWrapper< setupContext: CoreSetup | CorePreboot, plugins: TPluginsSetup ): TSetup | Promise { - this.instance = this.createPluginInstance(); + if (!this.instance) { + throw new Error('The plugin is not initialized. Call the init method first.'); + } if (this.isPrebootPluginInstance(this.instance)) { return this.instance.setup(setupContext as CorePreboot, plugins); @@ -170,7 +176,7 @@ export class PluginWrapper< return configDescriptor; } - private createPluginInstance() { + private async createPluginInstance() { this.log.debug('Initializing plugin'); // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -186,7 +192,7 @@ export class PluginWrapper< throw new Error(`Definition of plugin "${this.name}" should be a function (${this.path}).`); } - const instance = initializer(this.initializerContext); + const instance = await initializer(this.initializerContext); if (!instance || typeof instance !== 'object') { throw new Error( `Initializer for plugin "${ diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugins_system.ts b/packages/core/plugins/core-plugins-server-internal/src/plugins_system.ts index a7ca6d64da545..6b5d14846b754 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugins_system.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugins_system.ts @@ -131,6 +131,7 @@ export class PluginsSystem { }); } + await plugin.init(); let contract: unknown; const contractOrPromise = plugin.setup(pluginSetupContext, pluginDepContracts); if (isPromise(contractOrPromise)) { diff --git a/packages/core/plugins/core-plugins-server/src/types.ts b/packages/core/plugins/core-plugins-server/src/types.ts index e518bd7db7eb6..297bdb147c292 100644 --- a/packages/core/plugins/core-plugins-server/src/types.ts +++ b/packages/core/plugins/core-plugins-server/src/types.ts @@ -473,7 +473,8 @@ export type PluginInitializer< TPluginsStart extends object = object > = ( core: PluginInitializerContext -) => +) => Promise< | Plugin | PrebootPlugin - | AsyncPlugin; + | AsyncPlugin +>; diff --git a/src/plugins/advanced_settings/server/index.ts b/src/plugins/advanced_settings/server/index.ts index f78be24868a5c..de573ad54cd66 100644 --- a/src/plugins/advanced_settings/server/index.ts +++ b/src/plugins/advanced_settings/server/index.ts @@ -7,9 +7,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { AdvancedSettingsServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (initContext: PluginInitializerContext) => - new AdvancedSettingsServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { AdvancedSettingsServerPlugin } = await import('./plugin'); + return new AdvancedSettingsServerPlugin(initContext); +}; diff --git a/src/plugins/bfetch/server/index.ts b/src/plugins/bfetch/server/index.ts index f0e6b15f99758..6e477df550419 100644 --- a/src/plugins/bfetch/server/index.ts +++ b/src/plugins/bfetch/server/index.ts @@ -7,10 +7,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { BfetchServerPlugin } from './plugin'; export type { BfetchServerSetup, BfetchServerStart, BatchProcessingRouteParams } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { BfetchServerPlugin } = await import('./plugin'); return new BfetchServerPlugin(initializerContext); } diff --git a/src/plugins/chart_expressions/expression_gauge/server/index.ts b/src/plugins/chart_expressions/expression_gauge/server/index.ts index b0539ab12b18c..9420c05feddf6 100644 --- a/src/plugins/chart_expressions/expression_gauge/server/index.ts +++ b/src/plugins/chart_expressions/expression_gauge/server/index.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ -import { ExpressionGaugePlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionGaugePlugin } = await import('./plugin'); return new ExpressionGaugePlugin(); } diff --git a/src/plugins/chart_expressions/expression_heatmap/server/index.ts b/src/plugins/chart_expressions/expression_heatmap/server/index.ts index fbbf8027eb343..869886ca210f1 100644 --- a/src/plugins/chart_expressions/expression_heatmap/server/index.ts +++ b/src/plugins/chart_expressions/expression_heatmap/server/index.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ -import { ExpressionHeatmapPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionHeatmapPlugin } = await import('./plugin'); return new ExpressionHeatmapPlugin(); } diff --git a/src/plugins/chart_expressions/expression_legacy_metric/server/index.ts b/src/plugins/chart_expressions/expression_legacy_metric/server/index.ts index 9c9c1641b68a8..6053a916e2b96 100644 --- a/src/plugins/chart_expressions/expression_legacy_metric/server/index.ts +++ b/src/plugins/chart_expressions/expression_legacy_metric/server/index.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ -import { ExpressionLegacyMetricPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionLegacyMetricPlugin } = await import('./plugin'); return new ExpressionLegacyMetricPlugin(); } diff --git a/src/plugins/chart_expressions/expression_metric/server/index.ts b/src/plugins/chart_expressions/expression_metric/server/index.ts index dfb442514d5f0..8bdbfd5b4f372 100644 --- a/src/plugins/chart_expressions/expression_metric/server/index.ts +++ b/src/plugins/chart_expressions/expression_metric/server/index.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ -import { ExpressionMetricPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionMetricPlugin } = await import('./plugin'); return new ExpressionMetricPlugin(); } diff --git a/src/plugins/chart_expressions/expression_partition_vis/server/index.ts b/src/plugins/chart_expressions/expression_partition_vis/server/index.ts index 98395d521e238..30a53f4cfb8d2 100755 --- a/src/plugins/chart_expressions/expression_partition_vis/server/index.ts +++ b/src/plugins/chart_expressions/expression_partition_vis/server/index.ts @@ -6,9 +6,8 @@ * Side Public License, v 1. */ -import { ExpressionPartitionVisPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionPartitionVisPlugin } = await import('./plugin'); return new ExpressionPartitionVisPlugin(); } diff --git a/src/plugins/chart_expressions/expression_tagcloud/server/index.ts b/src/plugins/chart_expressions/expression_tagcloud/server/index.ts index c944168271314..337d6cdc636cb 100644 --- a/src/plugins/chart_expressions/expression_tagcloud/server/index.ts +++ b/src/plugins/chart_expressions/expression_tagcloud/server/index.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ -import { ExpressionTagcloudPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionTagcloudPlugin } = await import('./plugin'); return new ExpressionTagcloudPlugin(); } diff --git a/src/plugins/chart_expressions/expression_xy/server/index.ts b/src/plugins/chart_expressions/expression_xy/server/index.ts index e529b2a15fe34..453e9ed3dc3d6 100755 --- a/src/plugins/chart_expressions/expression_xy/server/index.ts +++ b/src/plugins/chart_expressions/expression_xy/server/index.ts @@ -6,9 +6,8 @@ * Side Public License, v 1. */ -import { ExpressionXyPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ExpressionXyPlugin } = await import('./plugin'); return new ExpressionXyPlugin(); } diff --git a/src/plugins/charts/server/index.ts b/src/plugins/charts/server/index.ts index ec59c25b50e98..0317ad486c346 100644 --- a/src/plugins/charts/server/index.ts +++ b/src/plugins/charts/server/index.ts @@ -6,8 +6,10 @@ * Side Public License, v 1. */ -import { ChartsServerPlugin } from './plugin'; export type { CustomPaletteArguments, CustomPaletteState, SystemPaletteArguments } from '../common'; export { paletteIds } from '../common'; -export const plugin = () => new ChartsServerPlugin(); +export const plugin = async () => { + const { ChartsServerPlugin } = await import('./plugin'); + return new ChartsServerPlugin(); +}; diff --git a/src/plugins/console/server/index.ts b/src/plugins/console/server/index.ts index 84f0d5cbad250..5def502ed5a25 100644 --- a/src/plugins/console/server/index.ts +++ b/src/plugins/console/server/index.ts @@ -8,10 +8,12 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { ConsoleServerPlugin } from './plugin'; - export type { ConsoleSetup, ConsoleStart } from './types'; export { config } from './config'; -export const plugin = (ctx: PluginInitializerContext) => new ConsoleServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { ConsoleServerPlugin } = await import('./plugin'); + + return new ConsoleServerPlugin(ctx); +}; diff --git a/src/plugins/content_management/server/index.ts b/src/plugins/content_management/server/index.ts index cdd69cb99b296..3e8a540d3f6bb 100644 --- a/src/plugins/content_management/server/index.ts +++ b/src/plugins/content_management/server/index.ts @@ -7,9 +7,8 @@ */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { ContentManagementPlugin } from './plugin'; - -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ContentManagementPlugin } = await import('./plugin'); return new ContentManagementPlugin(initializerContext); } diff --git a/src/plugins/controls/server/index.ts b/src/plugins/controls/server/index.ts index cec761ae80e20..e003036dc8f47 100644 --- a/src/plugins/controls/server/index.ts +++ b/src/plugins/controls/server/index.ts @@ -6,8 +6,9 @@ * Side Public License, v 1. */ -import { ControlsPlugin } from './plugin'; - -export const plugin = () => new ControlsPlugin(); +export const plugin = async () => { + const { ControlsPlugin } = await import('./plugin'); + return new ControlsPlugin(); +}; export { initializeControlGroupTelemetry } from './control_group/control_group_telemetry'; diff --git a/src/plugins/custom_integrations/server/index.ts b/src/plugins/custom_integrations/server/index.ts index 95e181903e973..dcca939d117ce 100755 --- a/src/plugins/custom_integrations/server/index.ts +++ b/src/plugins/custom_integrations/server/index.ts @@ -8,12 +8,12 @@ import { schema } from '@kbn/config-schema'; import { PluginInitializerContext } from '@kbn/core/server'; -import { CustomIntegrationsPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CustomIntegrationsPlugin } = await import('./plugin'); return new CustomIntegrationsPlugin(initializerContext); } diff --git a/src/plugins/dashboard/server/index.ts b/src/plugins/dashboard/server/index.ts index 8dbc074fefa59..a1ac1e5d0fd9c 100644 --- a/src/plugins/dashboard/server/index.ts +++ b/src/plugins/dashboard/server/index.ts @@ -7,7 +7,6 @@ */ import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { DashboardPlugin } from './plugin'; import { configSchema, ConfigSchema } from '../config'; export const config: PluginConfigDescriptor = { @@ -20,7 +19,8 @@ export const config: PluginConfigDescriptor = { // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { DashboardPlugin } = await import('./plugin'); return new DashboardPlugin(initializerContext); } diff --git a/src/plugins/data/server/index.ts b/src/plugins/data/server/index.ts index 10368bd74281f..2f077e907dfca 100644 --- a/src/plugins/data/server/index.ts +++ b/src/plugins/data/server/index.ts @@ -8,7 +8,7 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { ConfigSchema, configSchema } from '../config'; -import { DataServerPlugin, DataPluginSetup, DataPluginStart } from './plugin'; +import type { DataServerPlugin, DataPluginSetup, DataPluginStart } from './plugin'; export { getEsQueryConfig, DEFAULT_QUERY_LANGUAGE } from '../common'; @@ -101,12 +101,13 @@ export { getTime, parseInterval } from '../common'; * @public */ -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { DataServerPlugin } = await import('./plugin'); return new DataServerPlugin(initializerContext); } export type { DataPluginSetup as PluginSetup, DataPluginStart as PluginStart }; -export { DataServerPlugin as Plugin }; +export type { DataServerPlugin as Plugin }; export const config: PluginConfigDescriptor = { deprecations: configDeprecationProvider, diff --git a/src/plugins/data_view_field_editor/server/index.ts b/src/plugins/data_view_field_editor/server/index.ts index 38ae28ebe9892..67fdafcbb3f39 100644 --- a/src/plugins/data_view_field_editor/server/index.ts +++ b/src/plugins/data_view_field_editor/server/index.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ import { PluginInitializerContext } from '@kbn/core/server'; -import { IndexPatternPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { IndexPatternPlugin } = await import('./plugin'); return new IndexPatternPlugin(initializerContext); } diff --git a/src/plugins/data_view_management/server/index.ts b/src/plugins/data_view_management/server/index.ts index 77e1ddf010eaf..7116606cab6fe 100644 --- a/src/plugins/data_view_management/server/index.ts +++ b/src/plugins/data_view_management/server/index.ts @@ -7,8 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { IndexPatternManagementPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { IndexPatternManagementPlugin } = await import('./plugin'); return new IndexPatternManagementPlugin(initializerContext); } diff --git a/src/plugins/data_views/server/index.ts b/src/plugins/data_views/server/index.ts index a489feabbf935..eba0a83a8df49 100644 --- a/src/plugins/data_views/server/index.ts +++ b/src/plugins/data_views/server/index.ts @@ -19,7 +19,7 @@ export type { } from './types'; import { PluginInitializerContext } from '@kbn/core/server'; -import { DataViewsServerPlugin } from './plugin'; +import type { DataViewsServerPlugin } from './plugin'; import { DataViewsServerPluginSetup, DataViewsServerPluginStart } from './types'; export type { dataViewsServiceFactory } from './data_views_service_factory'; @@ -28,7 +28,8 @@ export type { dataViewsServiceFactory } from './data_views_service_factory'; * @public */ -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { DataViewsServerPlugin } = await import('./plugin'); return new DataViewsServerPlugin(initializerContext); } @@ -36,7 +37,7 @@ export type { DataViewsServerPluginSetup as PluginSetup, DataViewsServerPluginStart as PluginStart, }; -export { DataViewsServerPlugin as Plugin }; +export type { DataViewsServerPlugin as Plugin }; const configSchema = schema.object({ scriptedFieldsEnabled: schema.conditional( diff --git a/src/plugins/dev_tools/server/index.ts b/src/plugins/dev_tools/server/index.ts index ca7d3a5b0eb32..0b572bdacf98c 100644 --- a/src/plugins/dev_tools/server/index.ts +++ b/src/plugins/dev_tools/server/index.ts @@ -7,9 +7,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { DevToolsServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (initContext: PluginInitializerContext) => - new DevToolsServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { DevToolsServerPlugin } = await import('./plugin'); + return new DevToolsServerPlugin(initContext); +}; diff --git a/src/plugins/discover/server/index.ts b/src/plugins/discover/server/index.ts index f899060f0304c..1b5a9b5080da9 100644 --- a/src/plugins/discover/server/index.ts +++ b/src/plugins/discover/server/index.ts @@ -9,7 +9,6 @@ import { KibanaRequest } from '@kbn/core/server'; import { DataPluginStart } from '@kbn/data-plugin/server/plugin'; import { ColumnsFromLocatorFn, SearchSourceFromLocatorFn, TitleFromLocatorFn } from './locator'; -import { DiscoverServerPlugin } from './plugin'; export interface DiscoverServerPluginStartDeps { data: DataPluginStart; @@ -29,4 +28,7 @@ export interface DiscoverServerPluginStart { locator: DiscoverServerPluginLocatorService; } -export const plugin = () => new DiscoverServerPlugin(); +export const plugin = async () => { + const { DiscoverServerPlugin } = await import('./plugin'); + return new DiscoverServerPlugin(); +}; diff --git a/src/plugins/embeddable/server/index.ts b/src/plugins/embeddable/server/index.ts index 4b93f0838c649..3ec552bacaa1d 100644 --- a/src/plugins/embeddable/server/index.ts +++ b/src/plugins/embeddable/server/index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { EmbeddableServerPlugin, EmbeddableSetup, EmbeddableStart } from './plugin'; +import { EmbeddableSetup, EmbeddableStart } from './plugin'; export type { EmbeddableSetup, EmbeddableStart }; @@ -14,4 +14,7 @@ export type { EnhancementRegistryDefinition } from './types'; export type { EmbeddableRegistryDefinition } from '../common'; -export const plugin = () => new EmbeddableServerPlugin(); +export const plugin = async () => { + const { EmbeddableServerPlugin } = await import('./plugin'); + return new EmbeddableServerPlugin(); +}; diff --git a/src/plugins/es_ui_shared/server/index.ts b/src/plugins/es_ui_shared/server/index.ts index 6fe8c913875a0..5e5d1010c3b24 100644 --- a/src/plugins/es_ui_shared/server/index.ts +++ b/src/plugins/es_ui_shared/server/index.ts @@ -9,7 +9,7 @@ export { handleEsError, parseEsError } from './errors'; /** dummy plugin*/ -export function plugin() { +export async function plugin() { return new (class EsUiSharedPlugin { setup() {} start() {} diff --git a/src/plugins/event_annotation/server/index.ts b/src/plugins/event_annotation/server/index.ts index 84fecda35d4f1..7952fb67d3f88 100644 --- a/src/plugins/event_annotation/server/index.ts +++ b/src/plugins/event_annotation/server/index.ts @@ -7,7 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core-plugins-server'; -import { EventAnnotationServerPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new EventAnnotationServerPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { EventAnnotationServerPlugin } = await import('./plugin'); + return new EventAnnotationServerPlugin(initializerContext); +}; diff --git a/src/plugins/expression_image/server/index.ts b/src/plugins/expression_image/server/index.ts index a4c6ee888d086..4f0087b6f262d 100755 --- a/src/plugins/expression_image/server/index.ts +++ b/src/plugins/expression_image/server/index.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -import { ExpressionImagePlugin } from './plugin'; - export type { ExpressionImagePluginSetup, ExpressionImagePluginStart } from './plugin'; -export function plugin() { +export async function plugin() { + const { ExpressionImagePlugin } = await import('./plugin'); return new ExpressionImagePlugin(); } diff --git a/src/plugins/expression_metric/server/index.ts b/src/plugins/expression_metric/server/index.ts index 0caafe1b69262..f9eb950b9ceae 100755 --- a/src/plugins/expression_metric/server/index.ts +++ b/src/plugins/expression_metric/server/index.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -import { ExpressionMetricPlugin } from './plugin'; - export type { ExpressionMetricPluginSetup, ExpressionMetricPluginStart } from './plugin'; -export function plugin() { +export async function plugin() { + const { ExpressionMetricPlugin } = await import('./plugin'); return new ExpressionMetricPlugin(); } diff --git a/src/plugins/expression_repeat_image/server/index.ts b/src/plugins/expression_repeat_image/server/index.ts index 07d0df9f78e05..0bc2ce114c5a6 100755 --- a/src/plugins/expression_repeat_image/server/index.ts +++ b/src/plugins/expression_repeat_image/server/index.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -import { ExpressionRepeatImagePlugin } from './plugin'; - export type { ExpressionRepeatImagePluginSetup, ExpressionRepeatImagePluginStart } from './plugin'; -export function plugin() { +export async function plugin() { + const { ExpressionRepeatImagePlugin } = await import('./plugin'); return new ExpressionRepeatImagePlugin(); } diff --git a/src/plugins/expression_reveal_image/server/index.ts b/src/plugins/expression_reveal_image/server/index.ts index b86c356974321..5675e194669d0 100644 --- a/src/plugins/expression_reveal_image/server/index.ts +++ b/src/plugins/expression_reveal_image/server/index.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -import { ExpressionRevealImagePlugin } from './plugin'; - export type { ExpressionRevealImagePluginSetup, ExpressionRevealImagePluginStart } from './plugin'; -export function plugin() { +export async function plugin() { + const { ExpressionRevealImagePlugin } = await import('./plugin'); return new ExpressionRevealImagePlugin(); } diff --git a/src/plugins/expression_shape/server/index.ts b/src/plugins/expression_shape/server/index.ts index 79da7a954c550..8fd3ea9d48fe9 100644 --- a/src/plugins/expression_shape/server/index.ts +++ b/src/plugins/expression_shape/server/index.ts @@ -6,10 +6,9 @@ * Side Public License, v 1. */ -import { ExpressionShapePlugin } from './plugin'; - export type { ExpressionShapePluginSetup, ExpressionShapePluginStart } from './plugin'; -export function plugin() { +export async function plugin() { + const { ExpressionShapePlugin } = await import('./plugin'); return new ExpressionShapePlugin(); } diff --git a/src/plugins/expressions/server/index.ts b/src/plugins/expressions/server/index.ts index 2e087d33c7aa5..b0e6cdc15f81a 100644 --- a/src/plugins/expressions/server/index.ts +++ b/src/plugins/expressions/server/index.ts @@ -7,13 +7,14 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ExpressionsServerPlugin } from './plugin'; +import type { ExpressionsServerPlugin } from './plugin'; export type { ExpressionsServerSetup, ExpressionsServerStart } from './plugin'; // Kibana Platform. export { ExpressionsServerPlugin as Plugin }; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ExpressionsServerPlugin } = await import('./plugin'); return new ExpressionsServerPlugin(initializerContext); } diff --git a/src/plugins/field_formats/server/index.ts b/src/plugins/field_formats/server/index.ts index bcc94c38dd0d8..b268665b0fa3f 100755 --- a/src/plugins/field_formats/server/index.ts +++ b/src/plugins/field_formats/server/index.ts @@ -7,10 +7,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { FieldFormatsPlugin } from './plugin'; export { DateFormat, DateNanosFormat } from './lib/converters'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { FieldFormatsPlugin } = await import('./plugin'); return new FieldFormatsPlugin(initializerContext); } diff --git a/src/plugins/files/server/index.ts b/src/plugins/files/server/index.ts index 181124fc27496..f02a0164b1f69 100755 --- a/src/plugins/files/server/index.ts +++ b/src/plugins/files/server/index.ts @@ -7,7 +7,6 @@ */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { FilesPlugin } from './plugin'; export type { FileClient, @@ -44,6 +43,7 @@ export type { } from './file_service'; export type { FileServiceFactory } from './file_service/file_service_factory'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { FilesPlugin } = await import('./plugin'); return new FilesPlugin(initializerContext); } diff --git a/src/plugins/ftr_apis/server/index.ts b/src/plugins/ftr_apis/server/index.ts index 5c33f6c4a067a..dfd8f08061931 100644 --- a/src/plugins/ftr_apis/server/index.ts +++ b/src/plugins/ftr_apis/server/index.ts @@ -7,9 +7,9 @@ */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { FtrApisPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { FtrApisPlugin } = await import('./plugin'); return new FtrApisPlugin(initializerContext); } diff --git a/src/plugins/guided_onboarding/server/index.ts b/src/plugins/guided_onboarding/server/index.ts index 823cc4daf3578..01d92ceaf4655 100755 --- a/src/plugins/guided_onboarding/server/index.ts +++ b/src/plugins/guided_onboarding/server/index.ts @@ -7,9 +7,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { GuidedOnboardingPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { GuidedOnboardingPlugin } = await import('./plugin'); return new GuidedOnboardingPlugin(initializerContext); } diff --git a/src/plugins/home/server/index.ts b/src/plugins/home/server/index.ts index d93f864fb7af4..d1763b2833b3e 100644 --- a/src/plugins/home/server/index.ts +++ b/src/plugins/home/server/index.ts @@ -23,7 +23,6 @@ export type { ScopedTutorialContextFactory, } from './services'; import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { HomeServerPlugin } from './plugin'; import { configSchema, ConfigSchema } from '../config'; export const config: PluginConfigDescriptor = { @@ -33,6 +32,9 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initContext: PluginInitializerContext) => new HomeServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { HomeServerPlugin } = await import('./plugin'); + return new HomeServerPlugin(initContext); +}; export { INSTRUCTION_VARIANT } from '../common/instruction_variant'; diff --git a/src/plugins/input_control_vis/server/index.ts b/src/plugins/input_control_vis/server/index.ts index 5054ac1ea2db5..46f04d5a4bbdf 100644 --- a/src/plugins/input_control_vis/server/index.ts +++ b/src/plugins/input_control_vis/server/index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { CoreSetup, PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; +import type { CoreSetup, PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import type { VisualizationsServerSetup } from '@kbn/visualizations-plugin/server'; import { configSchema, InputControlConfig } from '../config'; @@ -22,7 +22,7 @@ interface PluginSetupDependencies { visualizations: VisualizationsServerSetup; } -export const plugin = (initializerContext: PluginInitializerContext) => ({ +export const plugin = async (initializerContext: PluginInitializerContext) => ({ setup(core: CoreSetup, plugins: PluginSetupDependencies) { const { readOnly } = initializerContext.config.get(); if (readOnly) { diff --git a/src/plugins/interactive_setup/server/index.ts b/src/plugins/interactive_setup/server/index.ts index 885a4f4afa544..fc8c7fdd40b44 100644 --- a/src/plugins/interactive_setup/server/index.ts +++ b/src/plugins/interactive_setup/server/index.ts @@ -14,12 +14,14 @@ import type { } from '@kbn/core/server'; import { ConfigSchema } from './config'; -import { InteractiveSetupPlugin } from './plugin'; export const config: PluginConfigDescriptor> = { schema: ConfigSchema, }; -export const plugin: PluginInitializer = ( +export const plugin: PluginInitializer = async ( initializerContext: PluginInitializerContext -) => new InteractiveSetupPlugin(initializerContext); +) => { + const { InteractiveSetupPlugin } = await import('./plugin'); + return new InteractiveSetupPlugin(initializerContext); +}; diff --git a/src/plugins/kibana_usage_collection/server/index.ts b/src/plugins/kibana_usage_collection/server/index.ts index 2a674035ebe29..0b6b06559c2d2 100644 --- a/src/plugins/kibana_usage_collection/server/index.ts +++ b/src/plugins/kibana_usage_collection/server/index.ts @@ -7,11 +7,11 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { KibanaUsageCollectionPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { KibanaUsageCollectionPlugin } = await import('./plugin'); return new KibanaUsageCollectionPlugin(initializerContext); } diff --git a/src/plugins/links/server/index.ts b/src/plugins/links/server/index.ts index c60d084fa66d2..37ef2afdcb555 100644 --- a/src/plugins/links/server/index.ts +++ b/src/plugins/links/server/index.ts @@ -7,6 +7,8 @@ */ import { PluginInitializerContext } from '@kbn/core-plugins-server'; -import { LinksServerPlugin } from './plugin'; -export const plugin = (initContext: PluginInitializerContext) => new LinksServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { LinksServerPlugin } = await import('./plugin'); + return new LinksServerPlugin(initContext); +}; diff --git a/src/plugins/management/server/index.ts b/src/plugins/management/server/index.ts index 5d8ddf53fd068..5a0ee0a457dec 100644 --- a/src/plugins/management/server/index.ts +++ b/src/plugins/management/server/index.ts @@ -7,8 +7,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ManagementServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (initContext: PluginInitializerContext) => - new ManagementServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { ManagementServerPlugin } = await import('./plugin'); + return new ManagementServerPlugin(initContext); +}; diff --git a/src/plugins/maps_ems/server/index.ts b/src/plugins/maps_ems/server/index.ts index a0a5cd6c7e72e..0fea54b0ba974 100644 --- a/src/plugins/maps_ems/server/index.ts +++ b/src/plugins/maps_ems/server/index.ts @@ -6,17 +6,10 @@ * Side Public License, v 1. */ -import { - CoreSetup, - PluginInitializerContext, - Plugin, - PluginConfigDescriptor, -} from '@kbn/core/server'; -import { LicensingPluginSetup } from '@kbn/licensing-plugin/server'; -import { ILicense } from '@kbn/licensing-plugin/common/types'; +import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; import { MapConfig, mapConfigSchema } from '../config'; -import { EMSSettings, LICENSE_CHECK_ID } from '../common'; export type { EMSSettings } from '../common'; +export type { MapsEmsPluginServerSetup } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -32,48 +25,7 @@ export const config: PluginConfigDescriptor = { schema: mapConfigSchema, }; -export interface MapsEmsPluginServerSetup { - config: MapConfig; - createEMSSettings: () => EMSSettings; -} - -interface MapsEmsSetupServerDependencies { - licensing?: LicensingPluginSetup; -} - -export class MapsEmsPlugin implements Plugin { - readonly _initializerContext: PluginInitializerContext; - - constructor(initializerContext: PluginInitializerContext) { - this._initializerContext = initializerContext; - } - - public setup(core: CoreSetup, plugins: MapsEmsSetupServerDependencies) { - const mapConfig = this._initializerContext.config.get(); - - let isEnterprisePlus = false; - if (plugins.licensing) { - function updateLicenseState(license: ILicense) { - const enterprise = license.check(LICENSE_CHECK_ID, 'enterprise'); - isEnterprisePlus = enterprise.state === 'valid'; - } - - plugins.licensing.refresh().then(updateLicenseState); - plugins.licensing.license$.subscribe(updateLicenseState); - } - - return { - config: mapConfig, - createEMSSettings: () => { - return new EMSSettings(mapConfig, () => { - return isEnterprisePlus; - }); - }, - }; - } - - public start() {} -} - -export const plugin = (initializerContext: PluginInitializerContext) => - new MapsEmsPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { MapsEmsPlugin } = await import('./plugin'); + return new MapsEmsPlugin(initializerContext); +}; diff --git a/src/plugins/maps_ems/server/plugin.ts b/src/plugins/maps_ems/server/plugin.ts new file mode 100644 index 0000000000000..ebdc6814fd6eb --- /dev/null +++ b/src/plugins/maps_ems/server/plugin.ts @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ILicense, LicensingPluginSetup } from '@kbn/licensing-plugin/server'; +import { Plugin, PluginInitializerContext } from '@kbn/core-plugins-server'; +import { CoreSetup } from '@kbn/core-lifecycle-server'; +import { MapConfig } from '../config'; +import { LICENSE_CHECK_ID, EMSSettings } from '../common'; + +export interface MapsEmsPluginServerSetup { + config: MapConfig; + createEMSSettings: () => EMSSettings; +} + +interface MapsEmsSetupServerDependencies { + licensing?: LicensingPluginSetup; +} + +export class MapsEmsPlugin implements Plugin { + readonly _initializerContext: PluginInitializerContext; + + constructor(initializerContext: PluginInitializerContext) { + this._initializerContext = initializerContext; + } + + public setup(core: CoreSetup, plugins: MapsEmsSetupServerDependencies) { + const mapConfig = this._initializerContext.config.get(); + + let isEnterprisePlus = false; + if (plugins.licensing) { + function updateLicenseState(license: ILicense) { + const enterprise = license.check(LICENSE_CHECK_ID, 'enterprise'); + isEnterprisePlus = enterprise.state === 'valid'; + } + + plugins.licensing.refresh().then(updateLicenseState); + plugins.licensing.license$.subscribe(updateLicenseState); + } + + return { + config: mapConfig, + createEMSSettings: () => { + return new EMSSettings(mapConfig, () => { + return isEnterprisePlus; + }); + }, + }; + } + + public start() {} +} diff --git a/src/plugins/newsfeed/server/index.ts b/src/plugins/newsfeed/server/index.ts index 60df08a9b95e1..fe3acbeb40dac 100644 --- a/src/plugins/newsfeed/server/index.ts +++ b/src/plugins/newsfeed/server/index.ts @@ -7,7 +7,6 @@ */ import { PluginConfigDescriptor } from '@kbn/core/server'; -import { NewsfeedPlugin } from './plugin'; import { configSchema, NewsfeedConfigType } from './config'; export const config: PluginConfigDescriptor = { @@ -19,6 +18,7 @@ export const config: PluginConfigDescriptor = { }, }; -export function plugin() { +export async function plugin() { + const { NewsfeedPlugin } = await import('./plugin'); return new NewsfeedPlugin(); } diff --git a/src/plugins/presentation_util/server/index.ts b/src/plugins/presentation_util/server/index.ts index d1f9ef6da760a..dad4ef0e8362e 100644 --- a/src/plugins/presentation_util/server/index.ts +++ b/src/plugins/presentation_util/server/index.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { PresentationUtilPlugin } from './plugin'; - export { SETTING_CATEGORY } from './ui_settings'; -export const plugin = () => new PresentationUtilPlugin(); +export const plugin = async () => { + const { PresentationUtilPlugin } = await import('./plugin'); + return new PresentationUtilPlugin(); +}; diff --git a/src/plugins/saved_objects/public/index.ts b/src/plugins/saved_objects/public/index.ts index a159c3278f0b9..d343addcdcda1 100644 --- a/src/plugins/saved_objects/public/index.ts +++ b/src/plugins/saved_objects/public/index.ts @@ -19,4 +19,4 @@ export { checkForDuplicateTitle, saveWithConfirmation, isErrorNonFatal } from '. export type { SavedObjectSaveOpts, SavedObject, SavedObjectConfig } from './types'; export type { SavedObjectsStart, SavedObjectSetup } from './plugin'; -export const plugin = () => new SavedObjectsPublicPlugin(); +export const plugin = async () => new SavedObjectsPublicPlugin(); diff --git a/src/plugins/saved_objects_finder/server/index.ts b/src/plugins/saved_objects_finder/server/index.ts index 5d73b4387c9ff..fb5abfd46f7d9 100644 --- a/src/plugins/saved_objects_finder/server/index.ts +++ b/src/plugins/saved_objects_finder/server/index.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ -import { SavedObjectsServerPlugin } from './plugin'; - -export const plugin = () => new SavedObjectsServerPlugin(); +export const plugin = async () => { + const { SavedObjectsServerPlugin } = await import('./plugin'); + return new SavedObjectsServerPlugin(); +}; diff --git a/src/plugins/saved_objects_management/server/index.ts b/src/plugins/saved_objects_management/server/index.ts index 1ec0db16fd62b..e602a0fdae0f3 100644 --- a/src/plugins/saved_objects_management/server/index.ts +++ b/src/plugins/saved_objects_management/server/index.ts @@ -7,10 +7,11 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SavedObjectsManagementPlugin } from './plugin'; -export const plugin = (context: PluginInitializerContext) => - new SavedObjectsManagementPlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { SavedObjectsManagementPlugin } = await import('./plugin'); + return new SavedObjectsManagementPlugin(context); +}; export type { SavedObjectsManagementPluginSetup, diff --git a/src/plugins/saved_search/server/index.ts b/src/plugins/saved_search/server/index.ts index 056de3732b474..6c08bad317b9c 100644 --- a/src/plugins/saved_search/server/index.ts +++ b/src/plugins/saved_search/server/index.ts @@ -7,9 +7,10 @@ */ import type { PluginInitializerContext } from '@kbn/core-plugins-server'; -import { SavedSearchServerPlugin } from './plugin'; export { getSavedSearch } from './services/saved_searches'; -export const plugin = (initContext: PluginInitializerContext) => - new SavedSearchServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { SavedSearchServerPlugin } = await import('./plugin'); + return new SavedSearchServerPlugin(initContext); +}; diff --git a/src/plugins/screenshot_mode/server/index.ts b/src/plugins/screenshot_mode/server/index.ts index cc5d45b7be732..55dfd3967f4e4 100644 --- a/src/plugins/screenshot_mode/server/index.ts +++ b/src/plugins/screenshot_mode/server/index.ts @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -import { ScreenshotModePlugin } from './plugin'; - export { setScreenshotModeEnabled, KBN_SCREENSHOT_MODE_HEADER, @@ -20,6 +18,7 @@ export type { ScreenshotModePluginStart, } from './types'; -export function plugin() { +export async function plugin() { + const { ScreenshotModePlugin } = await import('./plugin'); return new ScreenshotModePlugin(); } diff --git a/src/plugins/share/server/index.ts b/src/plugins/share/server/index.ts index c55d91d053b50..d38575a3b7cd4 100644 --- a/src/plugins/share/server/index.ts +++ b/src/plugins/share/server/index.ts @@ -7,12 +7,12 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SharePlugin } from './plugin'; export type { SharePluginSetup, SharePluginStart } from './plugin'; export { CSV_QUOTE_VALUES_SETTING, CSV_SEPARATOR_SETTING } from '../common/constants'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { SharePlugin } = await import('./plugin'); return new SharePlugin(initializerContext); } diff --git a/src/plugins/telemetry/server/index.ts b/src/plugins/telemetry/server/index.ts index 3c67764953ef4..85096e763259b 100644 --- a/src/plugins/telemetry/server/index.ts +++ b/src/plugins/telemetry/server/index.ts @@ -8,13 +8,14 @@ import type { PluginInitializerContext } from '@kbn/core/server'; import type { TelemetryConfigType } from './config'; -import { TelemetryPlugin } from './plugin'; export { config } from './config'; export type { TelemetryPluginSetup, TelemetryPluginStart } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new TelemetryPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { TelemetryPlugin } = await import('./plugin'); + return new TelemetryPlugin(initializerContext); +}; export { getClusterUuids, getLocalStats } from './telemetry_collection'; export type { diff --git a/src/plugins/telemetry_collection_manager/server/index.ts b/src/plugins/telemetry_collection_manager/server/index.ts index ededc6abb87dd..d588a18b4e91f 100644 --- a/src/plugins/telemetry_collection_manager/server/index.ts +++ b/src/plugins/telemetry_collection_manager/server/index.ts @@ -7,12 +7,12 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { TelemetryCollectionManagerPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { TelemetryCollectionManagerPlugin } = await import('./plugin'); return new TelemetryCollectionManagerPlugin(initializerContext); } diff --git a/src/plugins/ui_actions_enhanced/server/index.ts b/src/plugins/ui_actions_enhanced/server/index.ts index 04df6d4b1e841..bb62e2b86a19c 100644 --- a/src/plugins/ui_actions_enhanced/server/index.ts +++ b/src/plugins/ui_actions_enhanced/server/index.ts @@ -6,14 +6,13 @@ * Side Public License, v 1. */ -import { AdvancedUiActionsServerPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { AdvancedUiActionsServerPlugin } = await import('./plugin'); return new AdvancedUiActionsServerPlugin(); } -export { AdvancedUiActionsServerPlugin as Plugin }; export type { + AdvancedUiActionsServerPlugin as Plugin, SetupContract as AdvancedUiActionsSetup, StartContract as AdvancedUiActionsStart, } from './plugin'; diff --git a/src/plugins/unified_search/server/index.ts b/src/plugins/unified_search/server/index.ts index d1948f32e2fe9..8f786e0ed1077 100644 --- a/src/plugins/unified_search/server/index.ts +++ b/src/plugins/unified_search/server/index.ts @@ -8,7 +8,7 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { ConfigSchema, configSchema } from '../config'; -import { +import type { UnifiedSearchServerPlugin, UnifiedSearchServerPluginSetup, UnifiedSearchServerPluginStart, @@ -21,7 +21,8 @@ import { autocompleteConfigDeprecationProvider } from './config_deprecations'; * @public */ -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { UnifiedSearchServerPlugin } = await import('./plugin'); return new UnifiedSearchServerPlugin(initializerContext); } @@ -29,7 +30,7 @@ export type { UnifiedSearchServerPluginSetup as PluginSetup, UnifiedSearchServerPluginStart as PluginStart, }; -export { UnifiedSearchServerPlugin as Plugin }; +export type { UnifiedSearchServerPlugin as Plugin }; export const config: PluginConfigDescriptor = { deprecations: autocompleteConfigDeprecationProvider, diff --git a/src/plugins/usage_collection/server/index.ts b/src/plugins/usage_collection/server/index.ts index 7e66b1bd323b0..38298b42ed9c1 100644 --- a/src/plugins/usage_collection/server/index.ts +++ b/src/plugins/usage_collection/server/index.ts @@ -7,7 +7,6 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { UsageCollectionPlugin } from './plugin'; export type { Collector, @@ -31,5 +30,7 @@ export { USAGE_COUNTERS_SAVED_OBJECT_TYPE, serializeCounterKey } from './usage_c export type { UsageCollectionSetup } from './plugin'; export { config } from './config'; -export const plugin = (initializerContext: PluginInitializerContext) => - new UsageCollectionPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { UsageCollectionPlugin } = await import('./plugin'); + return new UsageCollectionPlugin(initializerContext); +}; diff --git a/src/plugins/vis_type_markdown/server/index.ts b/src/plugins/vis_type_markdown/server/index.ts index d2deba39e9987..3f3bae7d810d6 100644 --- a/src/plugins/vis_type_markdown/server/index.ts +++ b/src/plugins/vis_type_markdown/server/index.ts @@ -17,7 +17,7 @@ export const config: PluginConfigDescriptor = { ], }; -export const plugin = () => ({ +export const plugin = async () => ({ setup() {}, start() {}, }); diff --git a/src/plugins/vis_types/gauge/server/index.ts b/src/plugins/vis_types/gauge/server/index.ts index bffab6592194f..e6d35075c8fb0 100755 --- a/src/plugins/vis_types/gauge/server/index.ts +++ b/src/plugins/vis_types/gauge/server/index.ts @@ -8,7 +8,6 @@ import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; import { configSchema, GaugeConfig } from '../config'; -import { VisTypeGaugeServerPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -17,5 +16,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new VisTypeGaugeServerPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { VisTypeGaugeServerPlugin } = await import('./plugin'); + return new VisTypeGaugeServerPlugin(initializerContext); +}; diff --git a/src/plugins/vis_types/heatmap/server/index.ts b/src/plugins/vis_types/heatmap/server/index.ts index 752bf1a381563..34c3783b62c9b 100644 --- a/src/plugins/vis_types/heatmap/server/index.ts +++ b/src/plugins/vis_types/heatmap/server/index.ts @@ -8,7 +8,6 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, HeatmapConfig } from '../config'; -import { VisTypeHeatmapServerPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -17,5 +16,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new VisTypeHeatmapServerPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { VisTypeHeatmapServerPlugin } = await import('./plugin'); + return new VisTypeHeatmapServerPlugin(initializerContext); +}; diff --git a/src/plugins/vis_types/metric/server/index.ts b/src/plugins/vis_types/metric/server/index.ts index 49359ab970e05..bc8d0b0f0f685 100644 --- a/src/plugins/vis_types/metric/server/index.ts +++ b/src/plugins/vis_types/metric/server/index.ts @@ -22,7 +22,7 @@ interface PluginSetupDependencies { visualizations: VisualizationsServerSetup; } -export const plugin = (initializerContext: PluginInitializerContext) => ({ +export const plugin = async (initializerContext: PluginInitializerContext) => ({ setup(core: CoreSetup, plugins: PluginSetupDependencies) { const { readOnly } = initializerContext.config.get(); if (readOnly) { diff --git a/src/plugins/vis_types/pie/server/index.ts b/src/plugins/vis_types/pie/server/index.ts index e1b9c6187357d..6b139e916adc9 100644 --- a/src/plugins/vis_types/pie/server/index.ts +++ b/src/plugins/vis_types/pie/server/index.ts @@ -8,7 +8,6 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, PieConfig } from '../config'; -import { VisTypePieServerPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -17,5 +16,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new VisTypePieServerPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { VisTypePieServerPlugin } = await import('./plugin'); + return new VisTypePieServerPlugin(initializerContext); +}; diff --git a/src/plugins/vis_types/timelion/server/index.ts b/src/plugins/vis_types/timelion/server/index.ts index bdff2a33c3ab2..e9b312c8731b0 100644 --- a/src/plugins/vis_types/timelion/server/index.ts +++ b/src/plugins/vis_types/timelion/server/index.ts @@ -8,7 +8,6 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, TimelionConfig } from '../config'; -import { TimelionPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -18,5 +17,7 @@ export const config: PluginConfigDescriptor = { deprecations: ({ unused }) => [unused('graphiteUrls', { level: 'warning' })], }; -export const plugin = (initializerContext: PluginInitializerContext) => - new TimelionPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { TimelionPlugin } = await import('./plugin'); + return new TimelionPlugin(initializerContext); +}; diff --git a/src/plugins/vis_types/timeseries/server/index.ts b/src/plugins/vis_types/timeseries/server/index.ts index 0faecf4c03adc..9ecb8a92d27d8 100644 --- a/src/plugins/vis_types/timeseries/server/index.ts +++ b/src/plugins/vis_types/timeseries/server/index.ts @@ -8,7 +8,6 @@ import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; import { VisTypeTimeseriesConfig, config as configSchema } from '../config'; -import { VisTypeTimeseriesPlugin } from './plugin'; export type { VisTypeTimeseriesSetup } from './plugin'; @@ -21,7 +20,8 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { VisTypeTimeseriesPlugin } = await import('./plugin'); return new VisTypeTimeseriesPlugin(initializerContext); } diff --git a/src/plugins/vis_types/vega/server/index.ts b/src/plugins/vis_types/vega/server/index.ts index 42e03c0ceefc5..b761d69922372 100644 --- a/src/plugins/vis_types/vega/server/index.ts +++ b/src/plugins/vis_types/vega/server/index.ts @@ -9,7 +9,6 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, ConfigSchema } from '../config'; -import { VisTypeVegaPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -18,7 +17,8 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { VisTypeVegaPlugin } = await import('./plugin'); return new VisTypeVegaPlugin(initializerContext); } diff --git a/src/plugins/vis_types/vislib/server/index.ts b/src/plugins/vis_types/vislib/server/index.ts index 8c46f2810542d..03b3d03d7fc25 100644 --- a/src/plugins/vis_types/vislib/server/index.ts +++ b/src/plugins/vis_types/vislib/server/index.ts @@ -8,7 +8,6 @@ import { PluginConfigDescriptor } from '@kbn/core/server'; import { configSchema, VislibConfig } from '../config'; -import { VisTypeVislibServerPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -17,4 +16,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = () => new VisTypeVislibServerPlugin(); +export const plugin = async () => { + const { VisTypeVislibServerPlugin } = await import('./plugin'); + return new VisTypeVislibServerPlugin(); +}; diff --git a/src/plugins/vis_types/xy/server/index.ts b/src/plugins/vis_types/xy/server/index.ts index d6b73627dd73a..f0484adf9a5ec 100644 --- a/src/plugins/vis_types/xy/server/index.ts +++ b/src/plugins/vis_types/xy/server/index.ts @@ -8,7 +8,6 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, XyConfig } from '../config'; -import { VisTypeXYServerPlugin } from './plugin'; export const config: PluginConfigDescriptor = { exposeToBrowser: { @@ -17,5 +16,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new VisTypeXYServerPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { VisTypeXYServerPlugin } = await import('./plugin'); + return new VisTypeXYServerPlugin(initializerContext); +}; diff --git a/src/plugins/visualizations/server/index.ts b/src/plugins/visualizations/server/index.ts index f40fb9885388f..adb65507d409c 100644 --- a/src/plugins/visualizations/server/index.ts +++ b/src/plugins/visualizations/server/index.ts @@ -7,12 +7,12 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { VisualizationsPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { VisualizationsPlugin } = await import('./plugin'); return new VisualizationsPlugin(initializerContext); } diff --git a/test/analytics/plugins/analytics_ftr_helpers/server/index.ts b/test/analytics/plugins/analytics_ftr_helpers/server/index.ts index 637348226e25c..190ec73cdd08e 100644 --- a/test/analytics/plugins/analytics_ftr_helpers/server/index.ts +++ b/test/analytics/plugins/analytics_ftr_helpers/server/index.ts @@ -8,4 +8,4 @@ import { AnalyticsFTRHelpers } from './plugin'; -export const plugin = () => new AnalyticsFTRHelpers(); +export const plugin = async () => new AnalyticsFTRHelpers(); diff --git a/test/analytics/plugins/analytics_plugin_a/server/index.ts b/test/analytics/plugins/analytics_plugin_a/server/index.ts index 65d2593c427f5..3decfbd0b4201 100644 --- a/test/analytics/plugins/analytics_plugin_a/server/index.ts +++ b/test/analytics/plugins/analytics_plugin_a/server/index.ts @@ -8,4 +8,4 @@ import { AnalyticsPluginAPlugin } from './plugin'; -export const plugin = () => new AnalyticsPluginAPlugin(); +export const plugin = async () => new AnalyticsPluginAPlugin(); diff --git a/test/common/plugins/newsfeed/server/index.ts b/test/common/plugins/newsfeed/server/index.ts index 21e28f5435cc2..192de4a3c47e3 100644 --- a/test/common/plugins/newsfeed/server/index.ts +++ b/test/common/plugins/newsfeed/server/index.ts @@ -9,6 +9,6 @@ import type { PluginInitializerContext } from '@kbn/core/server'; import { NewsFeedSimulatorPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { return new NewsFeedSimulatorPlugin(initializerContext); } diff --git a/test/common/plugins/otel_metrics/server/index.ts b/test/common/plugins/otel_metrics/server/index.ts index eb5f587592cae..2e542342b04c0 100644 --- a/test/common/plugins/otel_metrics/server/index.ts +++ b/test/common/plugins/otel_metrics/server/index.ts @@ -8,4 +8,4 @@ import { OpenTelemetryUsageTest } from './plugin'; -export const plugin = () => new OpenTelemetryUsageTest(); +export const plugin = async () => new OpenTelemetryUsageTest(); diff --git a/test/health_gateway/plugins/status/server/index.ts b/test/health_gateway/plugins/status/server/index.ts index a71049da757d0..d37e063cbe12f 100644 --- a/test/health_gateway/plugins/status/server/index.ts +++ b/test/health_gateway/plugins/status/server/index.ts @@ -8,6 +8,6 @@ import { HealthGatewayStatusPlugin } from './plugin'; -export function plugin() { +export async function plugin() { return new HealthGatewayStatusPlugin(); } diff --git a/test/interactive_setup_api_integration/plugins/test_endpoints/server/index.ts b/test/interactive_setup_api_integration/plugins/test_endpoints/server/index.ts index 8af208ce69da9..838998c86d6a8 100644 --- a/test/interactive_setup_api_integration/plugins/test_endpoints/server/index.ts +++ b/test/interactive_setup_api_integration/plugins/test_endpoints/server/index.ts @@ -11,7 +11,9 @@ import path from 'path'; import type { PluginInitializer, PrebootPlugin } from '@kbn/core/server'; -export const plugin: PluginInitializer = (initializerContext): PrebootPlugin => ({ +export const plugin: PluginInitializer = async ( + initializerContext +): Promise => ({ setup: (core) => { core.http.registerRoutes('', (router) => { router.get( diff --git a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts index 0230677a9d7e1..004d5bda160f3 100644 --- a/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts +++ b/test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts @@ -9,4 +9,5 @@ import { PluginInitializer } from '@kbn/core/server'; import { TestPlugin, TestPluginSetup, TestPluginStart } from './plugin'; -export const plugin: PluginInitializer = () => new TestPlugin(); +export const plugin: PluginInitializer = async () => + new TestPlugin(); diff --git a/test/node_roles_functional/plugins/core_plugin_initializer_context/server/index.ts b/test/node_roles_functional/plugins/core_plugin_initializer_context/server/index.ts index c074b4997a7f8..fa2e178f6a688 100644 --- a/test/node_roles_functional/plugins/core_plugin_initializer_context/server/index.ts +++ b/test/node_roles_functional/plugins/core_plugin_initializer_context/server/index.ts @@ -9,5 +9,5 @@ import type { PluginInitializerContext } from '@kbn/core/server'; import { CorePluginInitializerContextPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => +export const plugin = async (initializerContext: PluginInitializerContext) => new CorePluginInitializerContextPlugin(initializerContext); diff --git a/test/plugin_functional/plugins/core_dynamic_resolving_a/server/index.ts b/test/plugin_functional/plugins/core_dynamic_resolving_a/server/index.ts index dc204bdfdea9e..2b673ae30180c 100644 --- a/test/plugin_functional/plugins/core_dynamic_resolving_a/server/index.ts +++ b/test/plugin_functional/plugins/core_dynamic_resolving_a/server/index.ts @@ -8,4 +8,4 @@ import { CoreDynamicResolvingAPlugin } from './plugin'; -export const plugin = () => new CoreDynamicResolvingAPlugin(); +export const plugin = async () => new CoreDynamicResolvingAPlugin(); diff --git a/test/plugin_functional/plugins/core_dynamic_resolving_b/server/index.ts b/test/plugin_functional/plugins/core_dynamic_resolving_b/server/index.ts index ed305f96d7bc9..57797605cd46e 100644 --- a/test/plugin_functional/plugins/core_dynamic_resolving_b/server/index.ts +++ b/test/plugin_functional/plugins/core_dynamic_resolving_b/server/index.ts @@ -8,4 +8,4 @@ import { CoreDynamicResolvingBPlugin } from './plugin'; -export const plugin = () => new CoreDynamicResolvingBPlugin(); +export const plugin = async () => new CoreDynamicResolvingBPlugin(); diff --git a/test/plugin_functional/plugins/core_http/server/index.ts b/test/plugin_functional/plugins/core_http/server/index.ts index 66c2bb9e676f3..7f95feacaf444 100644 --- a/test/plugin_functional/plugins/core_http/server/index.ts +++ b/test/plugin_functional/plugins/core_http/server/index.ts @@ -8,4 +8,4 @@ import { CoreHttpPlugin } from './plugin'; -export const plugin = () => new CoreHttpPlugin(); +export const plugin = async () => new CoreHttpPlugin(); diff --git a/test/plugin_functional/plugins/core_plugin_a/server/index.ts b/test/plugin_functional/plugins/core_plugin_a/server/index.ts index 7fad3cf7a9e3b..a64b4f81d205a 100644 --- a/test/plugin_functional/plugins/core_plugin_a/server/index.ts +++ b/test/plugin_functional/plugins/core_plugin_a/server/index.ts @@ -9,4 +9,4 @@ import { CorePluginAPlugin } from './plugin'; export type { PluginAApiRequestContext } from './plugin'; -export const plugin = () => new CorePluginAPlugin(); +export const plugin = async () => new CorePluginAPlugin(); diff --git a/test/plugin_functional/plugins/core_plugin_b/server/index.ts b/test/plugin_functional/plugins/core_plugin_b/server/index.ts index da2c29c64b0be..e12621c34b3d7 100644 --- a/test/plugin_functional/plugins/core_plugin_b/server/index.ts +++ b/test/plugin_functional/plugins/core_plugin_b/server/index.ts @@ -8,4 +8,4 @@ import { CorePluginBPlugin } from './plugin'; -export const plugin = () => new CorePluginBPlugin(); +export const plugin = async () => new CorePluginBPlugin(); diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts b/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts index 1968c011a327a..e7f934ac66a1c 100644 --- a/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts +++ b/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts @@ -9,4 +9,4 @@ import { CorePluginDeprecationsPlugin } from './plugin'; export { config } from './config'; -export const plugin = () => new CorePluginDeprecationsPlugin(); +export const plugin = async () => new CorePluginDeprecationsPlugin(); diff --git a/test/plugin_functional/plugins/core_plugin_execution_context/server/index.ts b/test/plugin_functional/plugins/core_plugin_execution_context/server/index.ts index 019e302096752..029710faab2c7 100644 --- a/test/plugin_functional/plugins/core_plugin_execution_context/server/index.ts +++ b/test/plugin_functional/plugins/core_plugin_execution_context/server/index.ts @@ -8,4 +8,4 @@ import { CorePluginExecutionContext } from './plugin'; -export const plugin = () => new CorePluginExecutionContext(); +export const plugin = async () => new CorePluginExecutionContext(); diff --git a/test/plugin_functional/plugins/core_plugin_route_timeouts/server/index.ts b/test/plugin_functional/plugins/core_plugin_route_timeouts/server/index.ts index 47dcc66303a4e..5fbb9113cb59c 100644 --- a/test/plugin_functional/plugins/core_plugin_route_timeouts/server/index.ts +++ b/test/plugin_functional/plugins/core_plugin_route_timeouts/server/index.ts @@ -8,4 +8,4 @@ import { CorePluginRouteTimeoutsPlugin } from './plugin'; -export const plugin = () => new CorePluginRouteTimeoutsPlugin(); +export const plugin = async () => new CorePluginRouteTimeoutsPlugin(); diff --git a/test/plugin_functional/plugins/data_search/server/index.ts b/test/plugin_functional/plugins/data_search/server/index.ts index f7fb397aaedaa..8d2412d0192d7 100644 --- a/test/plugin_functional/plugins/data_search/server/index.ts +++ b/test/plugin_functional/plugins/data_search/server/index.ts @@ -9,5 +9,5 @@ import { PluginInitializer } from '@kbn/core/server'; import { DataSearchTestPlugin, TestPluginSetup, TestPluginStart } from './plugin'; -export const plugin: PluginInitializer = () => +export const plugin: PluginInitializer = async () => new DataSearchTestPlugin(); diff --git a/test/plugin_functional/plugins/elasticsearch_client_plugin/server/index.ts b/test/plugin_functional/plugins/elasticsearch_client_plugin/server/index.ts index f484a8e30985a..6e5b765d3ab18 100644 --- a/test/plugin_functional/plugins/elasticsearch_client_plugin/server/index.ts +++ b/test/plugin_functional/plugins/elasticsearch_client_plugin/server/index.ts @@ -8,4 +8,4 @@ import { ElasticsearchClientPlugin } from './plugin'; -export const plugin = () => new ElasticsearchClientPlugin(); +export const plugin = async () => new ElasticsearchClientPlugin(); diff --git a/test/plugin_functional/plugins/index_patterns/server/index.ts b/test/plugin_functional/plugins/index_patterns/server/index.ts index e40b2e7534bfb..5f723ef27a884 100644 --- a/test/plugin_functional/plugins/index_patterns/server/index.ts +++ b/test/plugin_functional/plugins/index_patterns/server/index.ts @@ -16,4 +16,4 @@ import { export const plugin: PluginInitializer< IndexPatternsTestPluginSetup, IndexPatternsTestPluginStart -> = () => new IndexPatternsTestPlugin(); +> = async () => new IndexPatternsTestPlugin(); diff --git a/test/plugin_functional/plugins/rendering_plugin/server/index.ts b/test/plugin_functional/plugins/rendering_plugin/server/index.ts index 9c684205df36a..156c0ecf3484c 100644 --- a/test/plugin_functional/plugins/rendering_plugin/server/index.ts +++ b/test/plugin_functional/plugins/rendering_plugin/server/index.ts @@ -8,4 +8,4 @@ import { RenderingPlugin } from './plugin'; -export const plugin = () => new RenderingPlugin(); +export const plugin = async () => new RenderingPlugin(); diff --git a/test/plugin_functional/plugins/saved_object_export_transforms/server/index.ts b/test/plugin_functional/plugins/saved_object_export_transforms/server/index.ts index ff622c41ad367..758620d7a75ba 100644 --- a/test/plugin_functional/plugins/saved_object_export_transforms/server/index.ts +++ b/test/plugin_functional/plugins/saved_object_export_transforms/server/index.ts @@ -8,4 +8,4 @@ import { SavedObjectExportTransformsPlugin } from './plugin'; -export const plugin = () => new SavedObjectExportTransformsPlugin(); +export const plugin = async () => new SavedObjectExportTransformsPlugin(); diff --git a/test/plugin_functional/plugins/saved_object_import_warnings/server/index.ts b/test/plugin_functional/plugins/saved_object_import_warnings/server/index.ts index c6bbdda012b74..9f9d617a6a727 100644 --- a/test/plugin_functional/plugins/saved_object_import_warnings/server/index.ts +++ b/test/plugin_functional/plugins/saved_object_import_warnings/server/index.ts @@ -8,4 +8,4 @@ import { SavedObjectImportWarningsPlugin } from './plugin'; -export const plugin = () => new SavedObjectImportWarningsPlugin(); +export const plugin = async () => new SavedObjectImportWarningsPlugin(); diff --git a/test/plugin_functional/plugins/saved_objects_hidden_from_http_apis_type/server/index.ts b/test/plugin_functional/plugins/saved_objects_hidden_from_http_apis_type/server/index.ts index 6e0e8ae655479..af0e09a3ef067 100644 --- a/test/plugin_functional/plugins/saved_objects_hidden_from_http_apis_type/server/index.ts +++ b/test/plugin_functional/plugins/saved_objects_hidden_from_http_apis_type/server/index.ts @@ -8,4 +8,4 @@ import { SavedObjectsHiddenFromHttpApisTypePlugin } from './plugin'; -export const plugin = () => new SavedObjectsHiddenFromHttpApisTypePlugin(); +export const plugin = async () => new SavedObjectsHiddenFromHttpApisTypePlugin(); diff --git a/test/plugin_functional/plugins/saved_objects_hidden_type/server/index.ts b/test/plugin_functional/plugins/saved_objects_hidden_type/server/index.ts index 2093b6e8449a4..738bb64d61ec9 100644 --- a/test/plugin_functional/plugins/saved_objects_hidden_type/server/index.ts +++ b/test/plugin_functional/plugins/saved_objects_hidden_type/server/index.ts @@ -8,4 +8,4 @@ import { SavedObjectsHiddenTypePlugin } from './plugin'; -export const plugin = () => new SavedObjectsHiddenTypePlugin(); +export const plugin = async () => new SavedObjectsHiddenTypePlugin(); diff --git a/test/plugin_functional/plugins/ui_settings_plugin/server/index.ts b/test/plugin_functional/plugins/ui_settings_plugin/server/index.ts index 581277501a489..8df0dce5cebf4 100644 --- a/test/plugin_functional/plugins/ui_settings_plugin/server/index.ts +++ b/test/plugin_functional/plugins/ui_settings_plugin/server/index.ts @@ -8,4 +8,4 @@ import { UiSettingsPlugin } from './plugin'; -export const plugin = () => new UiSettingsPlugin(); +export const plugin = async () => new UiSettingsPlugin(); diff --git a/test/plugin_functional/plugins/usage_collection/server/index.ts b/test/plugin_functional/plugins/usage_collection/server/index.ts index 172f8491a1a40..aee68cb614f46 100644 --- a/test/plugin_functional/plugins/usage_collection/server/index.ts +++ b/test/plugin_functional/plugins/usage_collection/server/index.ts @@ -7,4 +7,4 @@ */ import { UsageCollectionTestPlugin } from './plugin'; -export const plugin = () => new UsageCollectionTestPlugin(); +export const plugin = async () => new UsageCollectionTestPlugin(); diff --git a/test/server_integration/plugins/status_plugin_a/server/index.ts b/test/server_integration/plugins/status_plugin_a/server/index.ts index cf221c00e32b0..9f001ed0133fe 100644 --- a/test/server_integration/plugins/status_plugin_a/server/index.ts +++ b/test/server_integration/plugins/status_plugin_a/server/index.ts @@ -8,4 +8,4 @@ import { StatusPluginAPlugin } from './plugin'; -export const plugin = () => new StatusPluginAPlugin(); +export const plugin = async () => new StatusPluginAPlugin(); diff --git a/test/server_integration/plugins/status_plugin_b/server/index.ts b/test/server_integration/plugins/status_plugin_b/server/index.ts index 2002d234827b9..db400f1a0e23a 100644 --- a/test/server_integration/plugins/status_plugin_b/server/index.ts +++ b/test/server_integration/plugins/status_plugin_b/server/index.ts @@ -8,4 +8,4 @@ import { StatusPluginBPlugin } from './plugin'; -export const plugin = () => new StatusPluginBPlugin(); +export const plugin = async () => new StatusPluginBPlugin(); diff --git a/x-pack/plugins/actions/server/index.ts b/x-pack/plugins/actions/server/index.ts index a82ec2fd1ce4a..39b94204520b7 100644 --- a/x-pack/plugins/actions/server/index.ts +++ b/x-pack/plugins/actions/server/index.ts @@ -7,7 +7,6 @@ import { get } from 'lodash'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { ActionsPlugin } from './plugin'; import { configSchema, ActionsConfig, CustomHostSettings } from './config'; import { ActionsClient as ActionsClientClass } from './actions_client'; import { ActionsAuthorization as ActionsAuthorizationClass } from './authorization/actions_authorization'; @@ -37,7 +36,10 @@ export { } from './lib'; export { ACTION_SAVED_OBJECT_TYPE } from './constants/saved_objects'; -export const plugin = (initContext: PluginInitializerContext) => new ActionsPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { ActionsPlugin } = await import('./plugin'); + return new ActionsPlugin(initContext); +}; export { SubActionConnector } from './sub_action_framework/sub_action_connector'; export { CaseConnector } from './sub_action_framework/case'; diff --git a/x-pack/plugins/aiops/server/index.ts b/x-pack/plugins/aiops/server/index.ts index 8dca6eb397d5e..e6b1dace67029 100755 --- a/x-pack/plugins/aiops/server/index.ts +++ b/x-pack/plugins/aiops/server/index.ts @@ -6,9 +6,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { AiopsPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { AiopsPlugin } = await import('./plugin'); return new AiopsPlugin(initializerContext); } diff --git a/x-pack/plugins/alerting/server/index.ts b/x-pack/plugins/alerting/server/index.ts index 200fe93931f86..b6962f65b4ab8 100644 --- a/x-pack/plugins/alerting/server/index.ts +++ b/x-pack/plugins/alerting/server/index.ts @@ -7,7 +7,6 @@ import type { PublicMethodsOf } from '@kbn/utility-types'; import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { RulesClient as RulesClientClass } from './rules_client'; -import { AlertingPlugin } from './plugin'; import { configSchema } from './config'; import { AlertsConfigType } from './types'; @@ -70,7 +69,10 @@ export { } from './alerts_service'; export { getDataStreamAdapter } from './alerts_service/lib/data_stream_adapter'; -export const plugin = (initContext: PluginInitializerContext) => new AlertingPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { AlertingPlugin } = await import('./plugin'); + return new AlertingPlugin(initContext); +}; export const config: PluginConfigDescriptor = { schema: configSchema, diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts index 1b8f8cb7c237e..5012526710a71 100644 --- a/x-pack/plugins/apm/server/index.ts +++ b/x-pack/plugins/apm/server/index.ts @@ -12,7 +12,6 @@ import { } from '@kbn/core/server'; import { maxSuggestions } from '@kbn/observability-plugin/common'; import { SearchAggregatedTransactionSetting } from '../common/aggregated_transactions'; -import { APMPlugin } from './plugin'; const disabledOnServerless = offeringBasedSchema({ serverless: schema.boolean({ @@ -125,8 +124,10 @@ export const config: PluginConfigDescriptor = { export type APMConfig = TypeOf; -export const plugin = (initContext: PluginInitializerContext) => - new APMPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { APMPlugin } = await import('./plugin'); + return new APMPlugin(initContext); +}; export { APM_SERVER_FEATURE_ID } from '../common/rules/apm_rule_types'; export { APMPlugin } from './plugin'; diff --git a/x-pack/plugins/apm_data_access/server/index.ts b/x-pack/plugins/apm_data_access/server/index.ts index 4ef9a47937733..f322ff2eb910d 100644 --- a/x-pack/plugins/apm_data_access/server/index.ts +++ b/x-pack/plugins/apm_data_access/server/index.ts @@ -7,7 +7,6 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { ApmDataAccessPlugin } from './plugin'; const configSchema = schema.object({ indices: schema.object({ @@ -78,7 +77,8 @@ export const config: PluginConfigDescriptor = { export type APMDataAccessConfig = TypeOf; export type APMIndices = APMDataAccessConfig['indices']; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ApmDataAccessPlugin } = await import('./plugin'); return new ApmDataAccessPlugin(initializerContext); } diff --git a/x-pack/plugins/asset_manager/server/index.ts b/x-pack/plugins/asset_manager/server/index.ts index 5dbecbee5f9da..86e5e855a74c9 100644 --- a/x-pack/plugins/asset_manager/server/index.ts +++ b/x-pack/plugins/asset_manager/server/index.ts @@ -7,12 +7,7 @@ import { PluginInitializerContext } from '@kbn/core-plugins-server'; import { AssetManagerConfig } from '../common/config'; -import { - AssetManagerServerPlugin, - AssetManagerServerPluginSetup, - AssetManagerServerPluginStart, - config, -} from './plugin'; +import { AssetManagerServerPluginSetup, AssetManagerServerPluginStart, config } from './plugin'; import type { WriteSamplesPostBody } from './routes/sample_assets'; export type { @@ -23,5 +18,7 @@ export type { }; export { config }; -export const plugin = (context: PluginInitializerContext) => - new AssetManagerServerPlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { AssetManagerServerPlugin } = await import('./plugin'); + return new AssetManagerServerPlugin(context); +}; diff --git a/x-pack/plugins/banners/server/index.ts b/x-pack/plugins/banners/server/index.ts index 053de8b5c12b2..4b029ad07743b 100644 --- a/x-pack/plugins/banners/server/index.ts +++ b/x-pack/plugins/banners/server/index.ts @@ -6,7 +6,9 @@ */ import { PluginInitializer } from '@kbn/core/server'; -import { BannersPlugin } from './plugin'; export { config } from './config'; -export const plugin: PluginInitializer<{}, {}, {}, {}> = (context) => new BannersPlugin(context); +export const plugin: PluginInitializer<{}, {}, {}, {}> = async (context) => { + const { BannersPlugin } = await import('./plugin'); + return new BannersPlugin(context); +}; diff --git a/x-pack/plugins/canvas/server/index.ts b/x-pack/plugins/canvas/server/index.ts index 74c5810481e00..c72530f911cc1 100644 --- a/x-pack/plugins/canvas/server/index.ts +++ b/x-pack/plugins/canvas/server/index.ts @@ -6,12 +6,13 @@ */ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { CanvasPlugin } from './plugin'; import { ConfigSchema } from './config'; export const config: PluginConfigDescriptor = { schema: ConfigSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new CanvasPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { CanvasPlugin } = await import('./plugin'); + return new CanvasPlugin(initializerContext); +}; diff --git a/x-pack/plugins/cases/server/index.ts b/x-pack/plugins/cases/server/index.ts index b1cadb43f147c..911c59bc4d46a 100644 --- a/x-pack/plugins/cases/server/index.ts +++ b/x-pack/plugins/cases/server/index.ts @@ -9,7 +9,6 @@ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core export { CasesClient } from './client'; import type { ConfigType } from './config'; import { ConfigSchema } from './config'; -import { CasePlugin } from './plugin'; export const config: PluginConfigDescriptor = { schema: ConfigSchema, @@ -22,7 +21,9 @@ export const config: PluginConfigDescriptor = { renameFromRoot('xpack.case.enabled', 'xpack.cases.enabled', { level: 'critical' }), ], }; -export const plugin = (initializerContext: PluginInitializerContext) => - new CasePlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { CasePlugin } = await import('./plugin'); + return new CasePlugin(initializerContext); +}; export type { CasesSetup, CasesStart } from './types'; diff --git a/x-pack/plugins/cloud/server/index.ts b/x-pack/plugins/cloud/server/index.ts index 0328ebe89e1cf..c9d5c44390442 100644 --- a/x-pack/plugins/cloud/server/index.ts +++ b/x-pack/plugins/cloud/server/index.ts @@ -6,10 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { CloudPlugin } from './plugin'; export type { CloudSetup, CloudStart } from './plugin'; export { config } from './config'; -export const plugin = (initializerContext: PluginInitializerContext) => { +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { CloudPlugin } = await import('./plugin'); return new CloudPlugin(initializerContext); }; diff --git a/x-pack/plugins/cloud_defend/server/index.ts b/x-pack/plugins/cloud_defend/server/index.ts index 2cb2e1c2b55e5..c03b311bd2494 100644 --- a/x-pack/plugins/cloud_defend/server/index.ts +++ b/x-pack/plugins/cloud_defend/server/index.ts @@ -6,12 +6,12 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { CloudDefendPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CloudDefendPlugin } = await import('./plugin'); return new CloudDefendPlugin(initializerContext); } diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/server/index.ts b/x-pack/plugins/cloud_integrations/cloud_chat/server/index.ts index 71f0c7c23355e..fee69b5f756fc 100755 --- a/x-pack/plugins/cloud_integrations/cloud_chat/server/index.ts +++ b/x-pack/plugins/cloud_integrations/cloud_chat/server/index.ts @@ -6,10 +6,10 @@ */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { CloudChatPlugin } from './plugin'; export { config } from './config'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CloudChatPlugin } = await import('./plugin'); return new CloudChatPlugin(initializerContext); } diff --git a/x-pack/plugins/cloud_integrations/cloud_data_migration/server/index.ts b/x-pack/plugins/cloud_integrations/cloud_data_migration/server/index.ts index 5d5388e653cc8..91f0552696bae 100644 --- a/x-pack/plugins/cloud_integrations/cloud_data_migration/server/index.ts +++ b/x-pack/plugins/cloud_integrations/cloud_data_migration/server/index.ts @@ -5,8 +5,9 @@ * 2.0. */ -import { CloudDataMigrationPlugin } from './plugin'; - export { config } from './config'; -export const plugin = () => new CloudDataMigrationPlugin(); +export const plugin = async () => { + const { CloudDataMigrationPlugin } = await import('./plugin'); + return new CloudDataMigrationPlugin(); +}; diff --git a/x-pack/plugins/cloud_integrations/cloud_experiments/server/index.ts b/x-pack/plugins/cloud_integrations/cloud_experiments/server/index.ts index 6222c8108c0f5..ebf82f07ea4c9 100755 --- a/x-pack/plugins/cloud_integrations/cloud_experiments/server/index.ts +++ b/x-pack/plugins/cloud_integrations/cloud_experiments/server/index.ts @@ -6,10 +6,10 @@ */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { CloudExperimentsPlugin } from './plugin'; export { config } from './config'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CloudExperimentsPlugin } = await import('./plugin'); return new CloudExperimentsPlugin(initializerContext); } diff --git a/x-pack/plugins/cloud_integrations/cloud_full_story/server/index.ts b/x-pack/plugins/cloud_integrations/cloud_full_story/server/index.ts index fe50e3d2944c3..55b049d66e264 100755 --- a/x-pack/plugins/cloud_integrations/cloud_full_story/server/index.ts +++ b/x-pack/plugins/cloud_integrations/cloud_full_story/server/index.ts @@ -6,10 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { CloudFullStoryPlugin } from './plugin'; export { config } from './config'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CloudFullStoryPlugin } = await import('./plugin'); return new CloudFullStoryPlugin(initializerContext); } diff --git a/x-pack/plugins/cloud_integrations/cloud_gain_sight/server/index.ts b/x-pack/plugins/cloud_integrations/cloud_gain_sight/server/index.ts index 3e104ddd68f6c..09d79aabf8f4d 100755 --- a/x-pack/plugins/cloud_integrations/cloud_gain_sight/server/index.ts +++ b/x-pack/plugins/cloud_integrations/cloud_gain_sight/server/index.ts @@ -6,10 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { CloudGainsightPlugin } from './plugin'; export { config } from './config'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CloudGainsightPlugin } = await import('./plugin'); return new CloudGainsightPlugin(initializerContext); } diff --git a/x-pack/plugins/cloud_security_posture/server/index.ts b/x-pack/plugins/cloud_security_posture/server/index.ts index 1462eccda6cca..038c013ba746b 100755 --- a/x-pack/plugins/cloud_security_posture/server/index.ts +++ b/x-pack/plugins/cloud_security_posture/server/index.ts @@ -5,11 +5,12 @@ * 2.0. */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { CspPlugin } from './plugin'; export type { CspServerPluginSetup, CspServerPluginStart } from './types'; -export const plugin = (initializerContext: PluginInitializerContext) => - new CspPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { CspPlugin } = await import('./plugin'); + return new CspPlugin(initializerContext); +}; export { config } from './config'; diff --git a/x-pack/plugins/cross_cluster_replication/server/index.ts b/x-pack/plugins/cross_cluster_replication/server/index.ts index a24e95bddede1..4a4e466327763 100644 --- a/x-pack/plugins/cross_cluster_replication/server/index.ts +++ b/x-pack/plugins/cross_cluster_replication/server/index.ts @@ -6,9 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { CrossClusterReplicationServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (pluginInitializerContext: PluginInitializerContext) => - new CrossClusterReplicationServerPlugin(pluginInitializerContext); +export const plugin = async (pluginInitializerContext: PluginInitializerContext) => { + const { CrossClusterReplicationServerPlugin } = await import('./plugin'); + return new CrossClusterReplicationServerPlugin(pluginInitializerContext); +}; diff --git a/x-pack/plugins/custom_branding/server/index.ts b/x-pack/plugins/custom_branding/server/index.ts index d0387671278d2..3ac85738baa6e 100755 --- a/x-pack/plugins/custom_branding/server/index.ts +++ b/x-pack/plugins/custom_branding/server/index.ts @@ -7,8 +7,7 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { CustomBrandingPlugin } from './plugin'; - -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { CustomBrandingPlugin } = await import('./plugin'); return new CustomBrandingPlugin(initializerContext); } diff --git a/x-pack/plugins/dashboard_enhanced/server/index.ts b/x-pack/plugins/dashboard_enhanced/server/index.ts index 8fa8ea33c1788..6b436893691c1 100644 --- a/x-pack/plugins/dashboard_enhanced/server/index.ts +++ b/x-pack/plugins/dashboard_enhanced/server/index.ts @@ -6,7 +6,6 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { DashboardEnhancedPlugin } from './plugin'; export type { SetupContract as DashboardEnhancedSetupContract, @@ -15,6 +14,7 @@ export type { StartDependencies as DashboardEnhancedStartDependencies, } from './plugin'; -export function plugin(context: PluginInitializerContext) { +export async function plugin(context: PluginInitializerContext) { + const { DashboardEnhancedPlugin } = await import('./plugin'); return new DashboardEnhancedPlugin(context); } diff --git a/x-pack/plugins/data_visualizer/server/index.ts b/x-pack/plugins/data_visualizer/server/index.ts index 08b06005539b0..1f15b498f8777 100644 --- a/x-pack/plugins/data_visualizer/server/index.ts +++ b/x-pack/plugins/data_visualizer/server/index.ts @@ -6,6 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { DataVisualizerPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => new DataVisualizerPlugin(); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { DataVisualizerPlugin } = await import('./plugin'); + return new DataVisualizerPlugin(); +}; diff --git a/x-pack/plugins/discover_enhanced/server/index.ts b/x-pack/plugins/discover_enhanced/server/index.ts index 95ce6a4b8d3ba..853d529d28c8e 100644 --- a/x-pack/plugins/discover_enhanced/server/index.ts +++ b/x-pack/plugins/discover_enhanced/server/index.ts @@ -6,8 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { DiscoverEnhancedPlugin } from './plugin'; export { config } from './config'; -export const plugin = (context: PluginInitializerContext) => new DiscoverEnhancedPlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { DiscoverEnhancedPlugin } = await import('./plugin'); + return new DiscoverEnhancedPlugin(context); +}; diff --git a/x-pack/plugins/ecs_data_quality_dashboard/server/index.ts b/x-pack/plugins/ecs_data_quality_dashboard/server/index.ts index e7b580e50a762..bd83becac07b3 100755 --- a/x-pack/plugins/ecs_data_quality_dashboard/server/index.ts +++ b/x-pack/plugins/ecs_data_quality_dashboard/server/index.ts @@ -6,12 +6,12 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { EcsDataQualityDashboardPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { EcsDataQualityDashboardPlugin } = await import('./plugin'); return new EcsDataQualityDashboardPlugin(initializerContext); } diff --git a/x-pack/plugins/elastic_assistant/server/index.ts b/x-pack/plugins/elastic_assistant/server/index.ts index a375e036d8238..0cccc1ba27a7a 100755 --- a/x-pack/plugins/elastic_assistant/server/index.ts +++ b/x-pack/plugins/elastic_assistant/server/index.ts @@ -6,9 +6,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ElasticAssistantPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ElasticAssistantPlugin } = await import('./plugin'); return new ElasticAssistantPlugin(initializerContext); } diff --git a/x-pack/plugins/encrypted_saved_objects/server/index.ts b/x-pack/plugins/encrypted_saved_objects/server/index.ts index 4a75e0f6855b8..8b3982c292caa 100644 --- a/x-pack/plugins/encrypted_saved_objects/server/index.ts +++ b/x-pack/plugins/encrypted_saved_objects/server/index.ts @@ -8,7 +8,6 @@ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { ConfigSchema } from './config'; -import { EncryptedSavedObjectsPlugin } from './plugin'; export type { EncryptedSavedObjectTypeRegistration, AttributeToEncrypt } from './crypto'; export { EncryptionError, EncryptionErrorOperation } from './crypto'; @@ -27,5 +26,7 @@ export type { export const config: PluginConfigDescriptor = { schema: ConfigSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new EncryptedSavedObjectsPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { EncryptedSavedObjectsPlugin } = await import('./plugin'); + return new EncryptedSavedObjectsPlugin(initializerContext); +}; diff --git a/x-pack/plugins/enterprise_search/server/index.ts b/x-pack/plugins/enterprise_search/server/index.ts index 3b9372f339acf..53d8cbca7f540 100644 --- a/x-pack/plugins/enterprise_search/server/index.ts +++ b/x-pack/plugins/enterprise_search/server/index.ts @@ -8,9 +8,8 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { EnterpriseSearchPlugin } from './plugin'; - -export const plugin = (initializerContext: PluginInitializerContext) => { +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { EnterpriseSearchPlugin } = await import('./plugin'); return new EnterpriseSearchPlugin(initializerContext); }; diff --git a/x-pack/plugins/event_log/server/index.ts b/x-pack/plugins/event_log/server/index.ts index cd386483fef8f..e070f0cf0c940 100644 --- a/x-pack/plugins/event_log/server/index.ts +++ b/x-pack/plugins/event_log/server/index.ts @@ -7,7 +7,6 @@ import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; import { ConfigSchema, IEventLogConfig } from './types'; -import { Plugin } from './plugin'; export { millisToNanos, nanosToMillis } from '../common'; @@ -30,4 +29,7 @@ export { createReadySignal } from './lib/ready_signal'; export const config: PluginConfigDescriptor = { schema: ConfigSchema, }; -export const plugin = (context: PluginInitializerContext) => new Plugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { Plugin } = await import('./plugin'); + return new Plugin(context); +}; diff --git a/x-pack/plugins/features/server/index.ts b/x-pack/plugins/features/server/index.ts index 5882d0a4e339a..b40094dee92d4 100644 --- a/x-pack/plugins/features/server/index.ts +++ b/x-pack/plugins/features/server/index.ts @@ -6,7 +6,6 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { FeaturesPlugin } from './plugin'; // These exports are part of public Features plugin contract, any change in signature of exported // functions or removal of exports should be considered as a breaking change. Ideally we should @@ -23,5 +22,7 @@ export type { export { KibanaFeature, ElasticsearchFeature } from '../common'; export type { PluginSetupContract, PluginStartContract } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new FeaturesPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { FeaturesPlugin } = await import('./plugin'); + return new FeaturesPlugin(initializerContext); +}; diff --git a/x-pack/plugins/file_upload/server/index.ts b/x-pack/plugins/file_upload/server/index.ts index c818e74c0ddc5..8078c19cc4f6f 100644 --- a/x-pack/plugins/file_upload/server/index.ts +++ b/x-pack/plugins/file_upload/server/index.ts @@ -6,7 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { FileUploadPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new FileUploadPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { FileUploadPlugin } = await import('./plugin'); + return new FileUploadPlugin(initializerContext); +}; diff --git a/x-pack/plugins/fleet/server/index.ts b/x-pack/plugins/fleet/server/index.ts index c928696e6e60a..829e017c67de0 100644 --- a/x-pack/plugins/fleet/server/index.ts +++ b/x-pack/plugins/fleet/server/index.ts @@ -7,8 +7,6 @@ import type { PluginInitializerContext } from '@kbn/core/server'; -import { FleetPlugin } from './plugin'; - export { buildAgentStatusRuntimeField } from './services/agents/build_status_runtime_field'; export type { AgentService, @@ -50,6 +48,7 @@ export type { FleetFileUpdatableFields, } from './services/files/types'; -export const plugin = (initializerContext: PluginInitializerContext) => { +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { FleetPlugin } = await import('./plugin'); return new FleetPlugin(initializerContext); }; diff --git a/x-pack/plugins/global_search/server/index.ts b/x-pack/plugins/global_search/server/index.ts index 107486c857f94..fb658271a1706 100644 --- a/x-pack/plugins/global_search/server/index.ts +++ b/x-pack/plugins/global_search/server/index.ts @@ -6,11 +6,7 @@ */ import { PluginInitializer } from '@kbn/core/server'; -import { - GlobalSearchPlugin, - GlobalSearchPluginSetupDeps, - GlobalSearchPluginStartDeps, -} from './plugin'; +import { GlobalSearchPluginSetupDeps, GlobalSearchPluginStartDeps } from './plugin'; import { GlobalSearchPluginSetup, GlobalSearchPluginStart } from './types'; export const plugin: PluginInitializer< @@ -18,7 +14,10 @@ export const plugin: PluginInitializer< GlobalSearchPluginStart, GlobalSearchPluginSetupDeps, GlobalSearchPluginStartDeps -> = (context) => new GlobalSearchPlugin(context); +> = async (context) => { + const { GlobalSearchPlugin } = await import('./plugin'); + return new GlobalSearchPlugin(context); +}; export { config } from './config'; diff --git a/x-pack/plugins/global_search_providers/server/index.ts b/x-pack/plugins/global_search_providers/server/index.ts index 92b3a4347492e..7205361566b86 100644 --- a/x-pack/plugins/global_search_providers/server/index.ts +++ b/x-pack/plugins/global_search_providers/server/index.ts @@ -6,7 +6,14 @@ */ import { PluginInitializer } from '@kbn/core/server'; -import { GlobalSearchProvidersPlugin, GlobalSearchProvidersPluginSetupDeps } from './plugin'; +import type { GlobalSearchProvidersPluginSetupDeps } from './plugin'; -export const plugin: PluginInitializer<{}, {}, GlobalSearchProvidersPluginSetupDeps, {}> = () => - new GlobalSearchProvidersPlugin(); +export const plugin: PluginInitializer< + {}, + {}, + GlobalSearchProvidersPluginSetupDeps, + {} +> = async () => { + const { GlobalSearchProvidersPlugin } = await import('./plugin'); + return new GlobalSearchProvidersPlugin(); +}; diff --git a/x-pack/plugins/graph/server/index.ts b/x-pack/plugins/graph/server/index.ts index 86dca6c119604..46877645a8503 100644 --- a/x-pack/plugins/graph/server/index.ts +++ b/x-pack/plugins/graph/server/index.ts @@ -8,10 +8,11 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, ConfigSchema } from '../config'; -import { GraphPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new GraphPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { GraphPlugin } = await import('./plugin'); + return new GraphPlugin(initializerContext); +}; export const config: PluginConfigDescriptor = { exposeToBrowser: { diff --git a/x-pack/plugins/grokdebugger/server/index.js b/x-pack/plugins/grokdebugger/server/index.js index 418959762f9ab..fcc537e64e34e 100644 --- a/x-pack/plugins/grokdebugger/server/index.js +++ b/x-pack/plugins/grokdebugger/server/index.js @@ -5,9 +5,10 @@ * 2.0. */ -import { Plugin, config } from './plugin'; +import { config } from './plugin'; -export function plugin() { +export async function plugin() { + const { Plugin } = await import('./plugin'); return new Plugin(); } diff --git a/x-pack/plugins/index_lifecycle_management/server/index.ts b/x-pack/plugins/index_lifecycle_management/server/index.ts index 2f4c3a4706534..b4789a4868eba 100644 --- a/x-pack/plugins/index_lifecycle_management/server/index.ts +++ b/x-pack/plugins/index_lifecycle_management/server/index.ts @@ -6,9 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { IndexLifecycleManagementServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (ctx: PluginInitializerContext) => - new IndexLifecycleManagementServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { IndexLifecycleManagementServerPlugin } = await import('./plugin'); + return new IndexLifecycleManagementServerPlugin(ctx); +}; diff --git a/x-pack/plugins/index_management/server/index.ts b/x-pack/plugins/index_management/server/index.ts index ab6b0741274ff..127599066ab66 100644 --- a/x-pack/plugins/index_management/server/index.ts +++ b/x-pack/plugins/index_management/server/index.ts @@ -7,11 +7,12 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { IndexMgmtServerPlugin } from './plugin'; - export { config } from './config'; -export const plugin = (context: PluginInitializerContext) => new IndexMgmtServerPlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { IndexMgmtServerPlugin } = await import('./plugin'); + return new IndexMgmtServerPlugin(context); +}; /** @public */ export type { Dependencies } from './types'; diff --git a/x-pack/plugins/infra/server/index.ts b/x-pack/plugins/infra/server/index.ts index 2bfd868831ecc..96ac6dc162c24 100644 --- a/x-pack/plugins/infra/server/index.ts +++ b/x-pack/plugins/infra/server/index.ts @@ -6,12 +6,13 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { config, InfraConfig, InfraServerPlugin } from './plugin'; +import { config, InfraConfig } from './plugin'; export type { InfraPluginSetup, InfraPluginStart, InfraRequestHandlerContext } from './types'; export type { InfraConfig }; export { config }; -export function plugin(context: PluginInitializerContext) { +export async function plugin(context: PluginInitializerContext) { + const { InfraServerPlugin } = await import('./plugin'); return new InfraServerPlugin(context); } diff --git a/x-pack/plugins/ingest_pipelines/server/index.ts b/x-pack/plugins/ingest_pipelines/server/index.ts index d120f60ef8a2d..aac84c37591db 100644 --- a/x-pack/plugins/ingest_pipelines/server/index.ts +++ b/x-pack/plugins/ingest_pipelines/server/index.ts @@ -5,8 +5,7 @@ * 2.0. */ -import { IngestPipelinesPlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { IngestPipelinesPlugin } = await import('./plugin'); return new IngestPipelinesPlugin(); } diff --git a/x-pack/plugins/kubernetes_security/server/index.ts b/x-pack/plugins/kubernetes_security/server/index.ts index 7ff5edf027a09..b51098c136ad0 100644 --- a/x-pack/plugins/kubernetes_security/server/index.ts +++ b/x-pack/plugins/kubernetes_security/server/index.ts @@ -6,8 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { KubernetesSecurityPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { KubernetesSecurityPlugin } = await import('./plugin'); return new KubernetesSecurityPlugin(initializerContext); } diff --git a/x-pack/plugins/lens/server/index.ts b/x-pack/plugins/lens/server/index.ts index 6b9f823c3bbc6..80a61445b9cdb 100644 --- a/x-pack/plugins/lens/server/index.ts +++ b/x-pack/plugins/lens/server/index.ts @@ -6,9 +6,11 @@ */ import type { PluginInitializerContext } from '@kbn/core-plugins-server'; -import { LensServerPlugin } from './plugin'; export type { LensServerPluginSetup } from './plugin'; -export const plugin = (initContext: PluginInitializerContext) => new LensServerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { LensServerPlugin } = await import('./plugin'); + return new LensServerPlugin(initContext); +}; export type { LensDocShape715 } from './migrations/types'; diff --git a/x-pack/plugins/license_management/server/index.ts b/x-pack/plugins/license_management/server/index.ts index 1a8eba1e2610e..55bd9e0f67fcf 100644 --- a/x-pack/plugins/license_management/server/index.ts +++ b/x-pack/plugins/license_management/server/index.ts @@ -7,8 +7,9 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { LicenseManagementServerPlugin } from './plugin'; - export { config } from './config'; -export const plugin = (ctx: PluginInitializerContext) => new LicenseManagementServerPlugin(); +export const plugin = async (ctx: PluginInitializerContext) => { + const { LicenseManagementServerPlugin } = await import('./plugin'); + return new LicenseManagementServerPlugin(); +}; diff --git a/x-pack/plugins/licensing/server/index.ts b/x-pack/plugins/licensing/server/index.ts index 4cfa04089d8c5..af95086815221 100644 --- a/x-pack/plugins/licensing/server/index.ts +++ b/x-pack/plugins/licensing/server/index.ts @@ -6,9 +6,11 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { LicensingPlugin } from './plugin'; -export const plugin = (context: PluginInitializerContext) => new LicensingPlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { LicensingPlugin } = await import('./plugin'); + return new LicensingPlugin(context); +}; export type { LicenseCheckState, diff --git a/x-pack/plugins/lists/server/index.ts b/x-pack/plugins/lists/server/index.ts index ef63343d8f5ea..f4d6805057c41 100644 --- a/x-pack/plugins/lists/server/index.ts +++ b/x-pack/plugins/lists/server/index.ts @@ -8,9 +8,9 @@ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { ConfigSchema } from './config'; -import { ListPlugin } from './plugin'; +import type { ListPlugin } from './plugin'; -// exporting these since its required at top level in siem plugin +// exporting these since it's required at top level in siem plugin export { ListClient } from './services/lists/list_client'; export type { CreateExceptionListItemOptions, @@ -40,5 +40,7 @@ export const config: PluginConfigDescriptor = { export { ErrorWithStatusCode as ListsErrorWithStatusCode } from './error_with_status_code'; -export const plugin = (initializerContext: PluginInitializerContext): ListPlugin => - new ListPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext): Promise => { + const { ListPlugin } = await import('./plugin'); + return new ListPlugin(initializerContext); +}; diff --git a/x-pack/plugins/log_explorer/server/index.ts b/x-pack/plugins/log_explorer/server/index.ts index 634e4cfe02566..38aab9b85065b 100644 --- a/x-pack/plugins/log_explorer/server/index.ts +++ b/x-pack/plugins/log_explorer/server/index.ts @@ -5,6 +5,7 @@ * 2.0. */ -import { LogExplorerServerPlugin } from './plugin'; - -export const plugin = () => new LogExplorerServerPlugin(); +export const plugin = async () => { + const { LogExplorerServerPlugin } = await import('./plugin'); + return new LogExplorerServerPlugin(); +}; diff --git a/x-pack/plugins/logs_shared/server/index.ts b/x-pack/plugins/logs_shared/server/index.ts index 1a894ddb52abd..efc7da6a9d326 100644 --- a/x-pack/plugins/logs_shared/server/index.ts +++ b/x-pack/plugins/logs_shared/server/index.ts @@ -6,7 +6,6 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { LogsSharedPlugin } from './plugin'; export type { LogsSharedPluginSetup, LogsSharedPluginStart } from './types'; export type { @@ -17,6 +16,7 @@ export type { export { config } from './config'; export { logViewSavedObjectName } from './saved_objects'; -export function plugin(context: PluginInitializerContext) { +export async function plugin(context: PluginInitializerContext) { + const { LogsSharedPlugin } = await import('./plugin'); return new LogsSharedPlugin(context); } diff --git a/x-pack/plugins/logstash/server/index.ts b/x-pack/plugins/logstash/server/index.ts index 3e89eeb9b5795..530ff1b7d5452 100644 --- a/x-pack/plugins/logstash/server/index.ts +++ b/x-pack/plugins/logstash/server/index.ts @@ -6,6 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { LogstashPlugin } from './plugin'; -export const plugin = (context: PluginInitializerContext) => new LogstashPlugin(context); +export const plugin = async (context: PluginInitializerContext) => { + const { LogstashPlugin } = await import('./plugin'); + return new LogstashPlugin(context); +}; diff --git a/x-pack/plugins/maps/server/index.ts b/x-pack/plugins/maps/server/index.ts index be2f235a51f4c..eadb5ccd3eaf9 100644 --- a/x-pack/plugins/maps/server/index.ts +++ b/x-pack/plugins/maps/server/index.ts @@ -7,7 +7,6 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { PluginConfigDescriptor } from '@kbn/core/server'; -import { MapsPlugin } from './plugin'; import { configSchema, MapsXPackConfig } from '../config'; export const config: PluginConfigDescriptor = { @@ -20,5 +19,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new MapsPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { MapsPlugin } = await import('./plugin'); + return new MapsPlugin(initializerContext); +}; diff --git a/x-pack/plugins/metrics_data_access/server/index.ts b/x-pack/plugins/metrics_data_access/server/index.ts index e76f2201b340a..1c79d5c5d423c 100644 --- a/x-pack/plugins/metrics_data_access/server/index.ts +++ b/x-pack/plugins/metrics_data_access/server/index.ts @@ -6,7 +6,6 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { MetricsDataPlugin } from './plugin'; export type { MetricsDataPluginSetup, @@ -20,6 +19,7 @@ export { metricsDataSourceSavedObjectName } from './saved_objects/metrics_data_s export { MetricsDataClient } from './client'; export { MetricsDataClientMock } from './client_mock'; -export function plugin(context: PluginInitializerContext) { +export async function plugin(context: PluginInitializerContext) { + const { MetricsDataPlugin } = await import('./plugin'); return new MetricsDataPlugin(context); } diff --git a/x-pack/plugins/ml/server/index.ts b/x-pack/plugins/ml/server/index.ts index 232df4ae7f1df..ea5a603741857 100644 --- a/x-pack/plugins/ml/server/index.ts +++ b/x-pack/plugins/ml/server/index.ts @@ -8,7 +8,6 @@ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { type ConfigSchema } from '../common/constants/app'; import { configSchema } from './config_schema'; -import { MlServerPlugin } from './plugin'; export type { MlPluginSetup, MlPluginStart } from './plugin'; export type { DatafeedStats as MlDatafeedStats, @@ -38,4 +37,7 @@ export const config: PluginConfigDescriptor = { }, }; -export const plugin = (ctx: PluginInitializerContext) => new MlServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { MlServerPlugin } = await import('./plugin'); + return new MlServerPlugin(ctx); +}; diff --git a/x-pack/plugins/monitoring/server/index.ts b/x-pack/plugins/monitoring/server/index.ts index ca55aa0770499..f39af9fffe7d6 100644 --- a/x-pack/plugins/monitoring/server/index.ts +++ b/x-pack/plugins/monitoring/server/index.ts @@ -7,7 +7,6 @@ import { TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { MonitoringPlugin } from './plugin'; import { configSchema } from './config'; import { deprecations } from './deprecations'; @@ -15,7 +14,10 @@ export type { KibanaSettingsCollector } from './kibana_monitoring/collectors'; export type { MonitoringConfig } from './config'; export type { MonitoringPluginSetup, IBulkUploader } from './types'; -export const plugin = (initContext: PluginInitializerContext) => new MonitoringPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { MonitoringPlugin } = await import('./plugin'); + return new MonitoringPlugin(initContext); +}; export const config: PluginConfigDescriptor> = { schema: configSchema, deprecations, diff --git a/x-pack/plugins/monitoring_collection/server/index.ts b/x-pack/plugins/monitoring_collection/server/index.ts index e6f15bd297dc8..8a795dbf802b6 100644 --- a/x-pack/plugins/monitoring_collection/server/index.ts +++ b/x-pack/plugins/monitoring_collection/server/index.ts @@ -7,15 +7,16 @@ import { TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { MonitoringCollectionPlugin } from './plugin'; import { configSchema } from './config'; export type { MonitoringCollectionConfig } from './config'; export type { MonitoringCollectionSetup, MetricResult, Metric } from './plugin'; -export const plugin = (initContext: PluginInitializerContext) => - new MonitoringCollectionPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { MonitoringCollectionPlugin } = await import('./plugin'); + return new MonitoringCollectionPlugin(initContext); +}; export const config: PluginConfigDescriptor> = { schema: configSchema, }; diff --git a/x-pack/plugins/notifications/server/index.ts b/x-pack/plugins/notifications/server/index.ts index 9e8785d680de5..4c3afb14f7a57 100755 --- a/x-pack/plugins/notifications/server/index.ts +++ b/x-pack/plugins/notifications/server/index.ts @@ -6,13 +6,13 @@ */ import type { PluginInitializerContext } from '@kbn/core/server'; -import { NotificationsPlugin } from './plugin'; export { config } from './config'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. export type { NotificationsPluginStart } from './types'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { NotificationsPlugin } = await import('./plugin'); return new NotificationsPlugin(initializerContext); } diff --git a/x-pack/plugins/observability/server/index.ts b/x-pack/plugins/observability/server/index.ts index 96231115e3fa2..fbe75c80cce07 100644 --- a/x-pack/plugins/observability/server/index.ts +++ b/x-pack/plugins/observability/server/index.ts @@ -10,7 +10,7 @@ import { offeringBasedSchema, schema, TypeOf } from '@kbn/config-schema'; import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { ObservabilityPlugin, ObservabilityPluginSetup } from './plugin'; +import type { ObservabilityPluginSetup } from './plugin'; import { createOrUpdateIndex, Mappings } from './utils/create_or_update_index'; import { createOrUpdateIndexTemplate } from './utils/create_or_update_index_template'; import { ScopedAnnotationsClient } from './lib/annotations/bootstrap_annotations'; @@ -75,8 +75,10 @@ export const config: PluginConfigDescriptor = { export type ObservabilityConfig = TypeOf; -export const plugin = (initContext: PluginInitializerContext) => - new ObservabilityPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { ObservabilityPlugin } = await import('./plugin'); + return new ObservabilityPlugin(initContext); +}; export type { Mappings, ObservabilityPluginSetup, ScopedAnnotationsClient }; export { diff --git a/x-pack/plugins/observability_ai_assistant/server/index.ts b/x-pack/plugins/observability_ai_assistant/server/index.ts index a6747758268b0..8660446357e34 100644 --- a/x-pack/plugins/observability_ai_assistant/server/index.ts +++ b/x-pack/plugins/observability_ai_assistant/server/index.ts @@ -7,7 +7,6 @@ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import type { ObservabilityAIAssistantConfig } from './config'; -import { ObservabilityAIAssistantPlugin } from './plugin'; export type { ObservabilityAIAssistantServerRouteRepository } from './routes/get_global_observability_ai_assistant_route_repository'; @@ -38,5 +37,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (ctx: PluginInitializerContext) => - new ObservabilityAIAssistantPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { ObservabilityAIAssistantPlugin } = await import('./plugin'); + return new ObservabilityAIAssistantPlugin(ctx); +}; diff --git a/x-pack/plugins/observability_log_explorer/server/index.ts b/x-pack/plugins/observability_log_explorer/server/index.ts index a487aefc8fd14..4d270d33f2e41 100644 --- a/x-pack/plugins/observability_log_explorer/server/index.ts +++ b/x-pack/plugins/observability_log_explorer/server/index.ts @@ -5,8 +5,9 @@ * 2.0. */ -import { ObservabilityLogExplorerServerPlugin } from './plugin'; - export { config } from './config'; -export const plugin = () => new ObservabilityLogExplorerServerPlugin(); +export const plugin = async () => { + const { ObservabilityLogExplorerServerPlugin } = await import('./plugin'); + return new ObservabilityLogExplorerServerPlugin(); +}; diff --git a/x-pack/plugins/observability_onboarding/server/index.ts b/x-pack/plugins/observability_onboarding/server/index.ts index ddc1c0ac79842..c22e7e92efdb9 100644 --- a/x-pack/plugins/observability_onboarding/server/index.ts +++ b/x-pack/plugins/observability_onboarding/server/index.ts @@ -10,7 +10,6 @@ import { PluginConfigDescriptor, PluginInitializerContext, } from '@kbn/core/server'; -import { ObservabilityOnboardingPlugin } from './plugin'; const configSchema = schema.object({ ui: schema.object({ @@ -35,7 +34,8 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ObservabilityOnboardingPlugin } = await import('./plugin'); return new ObservabilityOnboardingPlugin(initializerContext); } diff --git a/x-pack/plugins/osquery/server/index.ts b/x-pack/plugins/osquery/server/index.ts index 4f2c732620df9..f82552cec52fb 100644 --- a/x-pack/plugins/osquery/server/index.ts +++ b/x-pack/plugins/osquery/server/index.ts @@ -6,7 +6,6 @@ */ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { OsqueryPlugin } from './plugin'; import type { ConfigType } from '../common/config'; import { ConfigSchema } from '../common/config'; @@ -16,7 +15,9 @@ export const config: PluginConfigDescriptor = { actionEnabled: true, }, }; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { OsqueryPlugin } = await import('./plugin'); + return new OsqueryPlugin(initializerContext); } diff --git a/x-pack/plugins/painless_lab/server/index.ts b/x-pack/plugins/painless_lab/server/index.ts index d81147ed9e395..ad8203ecba194 100644 --- a/x-pack/plugins/painless_lab/server/index.ts +++ b/x-pack/plugins/painless_lab/server/index.ts @@ -7,7 +7,6 @@ import { offeringBasedSchema, schema, TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import { PainlessLabServerPlugin } from './plugin'; export const configSchema = schema.object({ enabled: offeringBasedSchema({ @@ -20,6 +19,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (ctx: PluginInitializerContext) => { +export const plugin = async (ctx: PluginInitializerContext) => { + const { PainlessLabServerPlugin } = await import('./plugin'); return new PainlessLabServerPlugin(ctx); }; diff --git a/x-pack/plugins/profiling/server/index.ts b/x-pack/plugins/profiling/server/index.ts index 25861fbcfc750..cbd429315cbb5 100644 --- a/x-pack/plugins/profiling/server/index.ts +++ b/x-pack/plugins/profiling/server/index.ts @@ -7,7 +7,6 @@ import { schema, TypeOf } from '@kbn/config-schema'; import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { ProfilingPlugin } from './plugin'; /** * These properties are used to create both the Collector and the Symbolizer integrations @@ -56,7 +55,8 @@ export const config: PluginConfigDescriptor = { // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ProfilingPlugin } = await import('./plugin'); return new ProfilingPlugin(initializerContext); } diff --git a/x-pack/plugins/profiling_data_access/server/index.ts b/x-pack/plugins/profiling_data_access/server/index.ts index d979d22f4a011..c245297c86bd8 100644 --- a/x-pack/plugins/profiling_data_access/server/index.ts +++ b/x-pack/plugins/profiling_data_access/server/index.ts @@ -7,7 +7,6 @@ import { schema, TypeOf } from '@kbn/config-schema'; import type { PluginInitializerContext } from '@kbn/core/server'; -import { ProfilingDataAccessPlugin } from './plugin'; import type { ProfilingDataAccessPluginSetup, ProfilingDataAccessPluginStart } from './plugin'; const configSchema = schema.object({ @@ -29,6 +28,7 @@ export type ProfilingConfig = TypeOf; export type { ProfilingDataAccessPluginSetup, ProfilingDataAccessPluginStart }; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ProfilingDataAccessPlugin } = await import('./plugin'); return new ProfilingDataAccessPlugin(initializerContext); } diff --git a/x-pack/plugins/remote_clusters/server/index.ts b/x-pack/plugins/remote_clusters/server/index.ts index 8325b869b150d..4702f6390d99a 100644 --- a/x-pack/plugins/remote_clusters/server/index.ts +++ b/x-pack/plugins/remote_clusters/server/index.ts @@ -6,9 +6,11 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { RemoteClustersServerPlugin } from './plugin'; export { config } from './config'; export type { RemoteClustersPluginSetup } from './plugin'; -export const plugin = (ctx: PluginInitializerContext) => new RemoteClustersServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { RemoteClustersServerPlugin } = await import('./plugin'); + return new RemoteClustersServerPlugin(ctx); +}; diff --git a/x-pack/plugins/reporting/server/index.ts b/x-pack/plugins/reporting/server/index.ts index 1089331ccd110..e6bee7dda8d9b 100644 --- a/x-pack/plugins/reporting/server/index.ts +++ b/x-pack/plugins/reporting/server/index.ts @@ -7,7 +7,6 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { ReportingConfigType } from './config'; -import { ReportingPlugin } from './plugin'; export { config } from './config'; @@ -17,8 +16,10 @@ export { config } from './config'; export type { ReportingSetup, ReportingStart } from './types'; // @internal -export const plugin = (initContext: PluginInitializerContext) => - new ReportingPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { ReportingPlugin } = await import('./plugin'); + return new ReportingPlugin(initContext); +}; // @internal export { ReportingCore } from './core'; diff --git a/x-pack/plugins/rollup/server/index.ts b/x-pack/plugins/rollup/server/index.ts index 8f41f7f9cf6fe..fd3f92e126840 100644 --- a/x-pack/plugins/rollup/server/index.ts +++ b/x-pack/plugins/rollup/server/index.ts @@ -6,9 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { RollupPlugin } from './plugin'; export { config } from './config'; -export const plugin = (pluginInitializerContext: PluginInitializerContext) => - new RollupPlugin(pluginInitializerContext); +export const plugin = async (pluginInitializerContext: PluginInitializerContext) => { + const { RollupPlugin } = await import('./plugin'); + return new RollupPlugin(pluginInitializerContext); +}; diff --git a/x-pack/plugins/rule_registry/server/index.ts b/x-pack/plugins/rule_registry/server/index.ts index c39aeb158be74..826d0d6f23bab 100644 --- a/x-pack/plugins/rule_registry/server/index.ts +++ b/x-pack/plugins/rule_registry/server/index.ts @@ -9,7 +9,6 @@ /* eslint-disable @kbn/eslint/no_export_all */ import { PluginInitializerContext } from '@kbn/core/server'; -import { RuleRegistryPlugin } from './plugin'; export type { RuleRegistryPluginSetupContract, RuleRegistryPluginStartContract } from './plugin'; export type { IRuleDataService, RuleDataPluginService } from './rule_data_plugin_service'; @@ -37,5 +36,7 @@ export { createPersistenceRuleTypeWrapper } from './utils/create_persistence_rul export * from './utils/persistence_types'; export type { AlertsClient } from './alert_data_client/alerts_client'; -export const plugin = (initContext: PluginInitializerContext) => - new RuleRegistryPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { RuleRegistryPlugin } = await import('./plugin'); + return new RuleRegistryPlugin(initContext); +}; diff --git a/x-pack/plugins/saved_objects_tagging/server/index.ts b/x-pack/plugins/saved_objects_tagging/server/index.ts index b9fcdcdbb7b4e..8c0d4f98b6994 100644 --- a/x-pack/plugins/saved_objects_tagging/server/index.ts +++ b/x-pack/plugins/saved_objects_tagging/server/index.ts @@ -6,7 +6,6 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SavedObjectTaggingPlugin } from './plugin'; export { config } from './config'; export type { @@ -17,5 +16,7 @@ export type { export type { IAssignmentService } from './services'; export type { ITagsClient } from '../common'; -export const plugin = (initializerContext: PluginInitializerContext) => - new SavedObjectTaggingPlugin(); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { SavedObjectTaggingPlugin } = await import('./plugin'); + return new SavedObjectTaggingPlugin(); +}; diff --git a/x-pack/plugins/screenshotting/server/index.ts b/x-pack/plugins/screenshotting/server/index.ts index 10d445b5e0eb1..c5755d93ebd1f 100755 --- a/x-pack/plugins/screenshotting/server/index.ts +++ b/x-pack/plugins/screenshotting/server/index.ts @@ -5,12 +5,13 @@ * 2.0. */ -import { ScreenshottingPlugin } from './plugin'; +import type { ScreenshottingPlugin } from './plugin'; /** * Screenshotting plugin entry point. */ -export function plugin(...args: ConstructorParameters) { +export async function plugin(...args: ConstructorParameters) { + const { ScreenshottingPlugin } = await import('./plugin'); return new ScreenshottingPlugin(...args); } diff --git a/x-pack/plugins/searchprofiler/server/index.ts b/x-pack/plugins/searchprofiler/server/index.ts index 95f5b28435738..53ef83285622e 100644 --- a/x-pack/plugins/searchprofiler/server/index.ts +++ b/x-pack/plugins/searchprofiler/server/index.ts @@ -6,8 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SearchProfilerServerPlugin } from './plugin'; -export const plugin = (ctx: PluginInitializerContext) => { +export const plugin = async (ctx: PluginInitializerContext) => { + const { SearchProfilerServerPlugin } = await import('./plugin'); return new SearchProfilerServerPlugin(ctx); }; diff --git a/x-pack/plugins/security/server/index.ts b/x-pack/plugins/security/server/index.ts index 4cf199ef6d686..3d5cd022b4c96 100644 --- a/x-pack/plugins/security/server/index.ts +++ b/x-pack/plugins/security/server/index.ts @@ -16,7 +16,6 @@ import type { RecursiveReadonly } from '@kbn/utility-types'; import { ConfigSchema } from './config'; import { securityConfigDeprecationProvider } from './config_deprecations'; import type { PluginSetupDependencies, SecurityPluginSetup, SecurityPluginStart } from './plugin'; -import { SecurityPlugin } from './plugin'; // These exports are part of public Security plugin contract, any change in signature of exported // functions or removal of exports should be considered as a breaking change. @@ -63,4 +62,7 @@ export const plugin: PluginInitializer< RecursiveReadonly, RecursiveReadonly, PluginSetupDependencies -> = (initializerContext: PluginInitializerContext) => new SecurityPlugin(initializerContext); +> = async (initializerContext: PluginInitializerContext) => { + const { SecurityPlugin } = await import('./plugin'); + return new SecurityPlugin(initializerContext); +}; diff --git a/x-pack/plugins/security_solution/server/index.ts b/x-pack/plugins/security_solution/server/index.ts index 21eb13b94df04..9c5c1a42749a6 100644 --- a/x-pack/plugins/security_solution/server/index.ts +++ b/x-pack/plugins/security_solution/server/index.ts @@ -6,14 +6,14 @@ */ import type { PluginInitializerContext, PluginConfigDescriptor } from '@kbn/core/server'; -import type { PluginSetup, PluginStart } from './plugin'; -import { Plugin } from './plugin'; +import type { Plugin, PluginSetup, PluginStart } from './plugin'; import type { ConfigSchema, ConfigType } from './config'; import { configSchema } from './config'; import { SIGNALS_INDEX_KEY } from '../common/constants'; import { AppClient } from './types'; -export const plugin = (context: PluginInitializerContext) => { +export const plugin = async (context: PluginInitializerContext) => { + const { Plugin } = await import('./plugin'); return new Plugin(context); }; diff --git a/x-pack/plugins/security_solution_ess/server/index.ts b/x-pack/plugins/security_solution_ess/server/index.ts index ebb28fda2cf0a..ad6f30ea6d771 100644 --- a/x-pack/plugins/security_solution_ess/server/index.ts +++ b/x-pack/plugins/security_solution_ess/server/index.ts @@ -7,12 +7,12 @@ import type { PluginInitializerContext } from '@kbn/core/server'; -import { SecuritySolutionEssPlugin } from './plugin'; export { config } from './config'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(_initializerContext: PluginInitializerContext) { +export async function plugin(_initializerContext: PluginInitializerContext) { + const { SecuritySolutionEssPlugin } = await import('./plugin'); return new SecuritySolutionEssPlugin(); } diff --git a/x-pack/plugins/security_solution_serverless/server/index.ts b/x-pack/plugins/security_solution_serverless/server/index.ts index 44ac7142240b9..a0e2cba23fd62 100644 --- a/x-pack/plugins/security_solution_serverless/server/index.ts +++ b/x-pack/plugins/security_solution_serverless/server/index.ts @@ -7,13 +7,13 @@ import type { PluginInitializerContext } from '@kbn/core/server'; -import { SecuritySolutionServerlessPlugin } from './plugin'; export { config } from './config'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { SecuritySolutionServerlessPlugin } = await import('./plugin'); return new SecuritySolutionServerlessPlugin(initializerContext); } diff --git a/x-pack/plugins/serverless/server/index.ts b/x-pack/plugins/serverless/server/index.ts index 04f08ac6ed4cc..350b7a6c27641 100644 --- a/x-pack/plugins/serverless/server/index.ts +++ b/x-pack/plugins/serverless/server/index.ts @@ -6,10 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ServerlessPlugin } from './plugin'; export { config } from './config'; -export const plugin = (initializerContext: PluginInitializerContext) => { +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { ServerlessPlugin } = await import('./plugin'); return new ServerlessPlugin(initializerContext); }; diff --git a/x-pack/plugins/serverless_observability/server/index.ts b/x-pack/plugins/serverless_observability/server/index.ts index c45e363a429bf..f0dbaa87b5c98 100644 --- a/x-pack/plugins/serverless_observability/server/index.ts +++ b/x-pack/plugins/serverless_observability/server/index.ts @@ -7,13 +7,13 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { ServerlessObservabilityPlugin } from './plugin'; export { config } from './config'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { ServerlessObservabilityPlugin } = await import('./plugin'); return new ServerlessObservabilityPlugin(initializerContext); } diff --git a/x-pack/plugins/serverless_search/public/index.ts b/x-pack/plugins/serverless_search/public/index.ts index 5031ccc61d1ac..c645efab33e37 100644 --- a/x-pack/plugins/serverless_search/public/index.ts +++ b/x-pack/plugins/serverless_search/public/index.ts @@ -5,11 +5,10 @@ * 2.0. */ -import { ServerlessSearchPlugin } from './plugin'; - // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin() { +export async function plugin() { + const { ServerlessSearchPlugin } = await import('./plugin'); return new ServerlessSearchPlugin(); } diff --git a/x-pack/plugins/session_view/server/index.ts b/x-pack/plugins/session_view/server/index.ts index cd524ea86cde2..f7fc70fd490a9 100644 --- a/x-pack/plugins/session_view/server/index.ts +++ b/x-pack/plugins/session_view/server/index.ts @@ -6,8 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SessionViewPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { SessionViewPlugin } = await import('./plugin'); return new SessionViewPlugin(initializerContext); } diff --git a/x-pack/plugins/snapshot_restore/server/index.ts b/x-pack/plugins/snapshot_restore/server/index.ts index 1375cec6846fe..dd2cab68dbdf4 100644 --- a/x-pack/plugins/snapshot_restore/server/index.ts +++ b/x-pack/plugins/snapshot_restore/server/index.ts @@ -6,8 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { SnapshotRestoreServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (ctx: PluginInitializerContext) => new SnapshotRestoreServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { SnapshotRestoreServerPlugin } = await import('./plugin'); + return new SnapshotRestoreServerPlugin(ctx); +}; diff --git a/x-pack/plugins/spaces/server/index.ts b/x-pack/plugins/spaces/server/index.ts index b7b97692f803e..ba949628c56e1 100644 --- a/x-pack/plugins/spaces/server/index.ts +++ b/x-pack/plugins/spaces/server/index.ts @@ -8,7 +8,6 @@ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { ConfigSchema } from './config'; -import { SpacesPlugin } from './plugin'; // These exports are part of public Spaces plugin contract, any change in signature of exported // functions or removal of exports should be considered as a breaking change. Ideally we should @@ -37,5 +36,7 @@ export const config: PluginConfigDescriptor = { }, }; -export const plugin = (initializerContext: PluginInitializerContext) => - new SpacesPlugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { SpacesPlugin } = await import('./plugin'); + return new SpacesPlugin(initializerContext); +}; diff --git a/x-pack/plugins/stack_alerts/server/index.ts b/x-pack/plugins/stack_alerts/server/index.ts index d6ca5109007d7..92fcf8730ec78 100644 --- a/x-pack/plugins/stack_alerts/server/index.ts +++ b/x-pack/plugins/stack_alerts/server/index.ts @@ -7,7 +7,6 @@ import { get } from 'lodash'; import { schema, TypeOf } from '@kbn/config-schema'; import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { AlertingBuiltinsPlugin } from './plugin'; export { ID as INDEX_THRESHOLD_ID } from './rule_types/index_threshold/rule_type'; export const configSchema = schema.object({}); @@ -34,4 +33,7 @@ export const config: PluginConfigDescriptor = { ], }; -export const plugin = (ctx: PluginInitializerContext) => new AlertingBuiltinsPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { AlertingBuiltinsPlugin } = await import('./plugin'); + return new AlertingBuiltinsPlugin(ctx); +}; diff --git a/x-pack/plugins/stack_connectors/server/index.ts b/x-pack/plugins/stack_connectors/server/index.ts index c41b13ee2b15c..4b8ae8580cf96 100644 --- a/x-pack/plugins/stack_connectors/server/index.ts +++ b/x-pack/plugins/stack_connectors/server/index.ts @@ -5,7 +5,6 @@ * 2.0. */ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { StackConnectorsPlugin } from './plugin'; import { configSchema, ConfigSchema } from './config'; export const config: PluginConfigDescriptor = { @@ -15,5 +14,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (initContext: PluginInitializerContext) => - new StackConnectorsPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { StackConnectorsPlugin } = await import('./plugin'); + return new StackConnectorsPlugin(initContext); +}; diff --git a/x-pack/plugins/synthetics/server/index.ts b/x-pack/plugins/synthetics/server/index.ts index 3ed326d1fc143..80cbe388a3015 100644 --- a/x-pack/plugins/synthetics/server/index.ts +++ b/x-pack/plugins/synthetics/server/index.ts @@ -6,9 +6,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { Plugin } from './plugin'; - -export const plugin = (initializerContext: PluginInitializerContext) => - new Plugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { Plugin } = await import('./plugin'); + return new Plugin(initializerContext); +}; export { config } from '../common/config'; diff --git a/x-pack/plugins/task_manager/server/index.ts b/x-pack/plugins/task_manager/server/index.ts index a6e9943df2d3c..95190f4468254 100644 --- a/x-pack/plugins/task_manager/server/index.ts +++ b/x-pack/plugins/task_manager/server/index.ts @@ -7,10 +7,12 @@ import { get } from 'lodash'; import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; -import { TaskManagerPlugin } from './plugin'; import { configSchema, TaskManagerConfig, MAX_WORKERS_LIMIT } from './config'; -export const plugin = (initContext: PluginInitializerContext) => new TaskManagerPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => { + const { TaskManagerPlugin } = await import('./plugin'); + return new TaskManagerPlugin(initContext); +}; export type { TaskInstance, diff --git a/x-pack/plugins/telemetry_collection_xpack/server/index.ts b/x-pack/plugins/telemetry_collection_xpack/server/index.ts index aab1bdb58fe59..85a3adc243236 100644 --- a/x-pack/plugins/telemetry_collection_xpack/server/index.ts +++ b/x-pack/plugins/telemetry_collection_xpack/server/index.ts @@ -5,13 +5,12 @@ * 2.0. */ -import { TelemetryCollectionXpackPlugin } from './plugin'; - export type { ESLicense } from './telemetry_collection'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export function plugin() { +export async function plugin() { + const { TelemetryCollectionXpackPlugin } = await import('./plugin'); return new TelemetryCollectionXpackPlugin(); } diff --git a/x-pack/plugins/threat_intelligence/server/index.ts b/x-pack/plugins/threat_intelligence/server/index.ts index c658a352a6077..ac4810ed94803 100644 --- a/x-pack/plugins/threat_intelligence/server/index.ts +++ b/x-pack/plugins/threat_intelligence/server/index.ts @@ -6,8 +6,8 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { ThreatIntelligencePlugin } from './plugin'; -export const plugin = (context: PluginInitializerContext) => { +export const plugin = async (context: PluginInitializerContext) => { + const { ThreatIntelligencePlugin } = await import('./plugin'); return new ThreatIntelligencePlugin(context); }; diff --git a/x-pack/plugins/timelines/server/index.ts b/x-pack/plugins/timelines/server/index.ts index c1f4c17e7d757..acdcc26a0a1aa 100644 --- a/x-pack/plugins/timelines/server/index.ts +++ b/x-pack/plugins/timelines/server/index.ts @@ -6,9 +6,9 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { TimelinesPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { TimelinesPlugin } = await import('./plugin'); return new TimelinesPlugin(initializerContext); } diff --git a/x-pack/plugins/transform/server/index.ts b/x-pack/plugins/transform/server/index.ts index 0688210a78137..2ae5ffbd3ccdf 100644 --- a/x-pack/plugins/transform/server/index.ts +++ b/x-pack/plugins/transform/server/index.ts @@ -7,8 +7,9 @@ import { PluginInitializerContext } from '@kbn/core/server'; -import { TransformServerPlugin } from './plugin'; - -export const plugin = (ctx: PluginInitializerContext) => new TransformServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { TransformServerPlugin } = await import('./plugin'); + return new TransformServerPlugin(ctx); +}; export { registerTransformHealthRuleType } from './lib/alerting'; diff --git a/x-pack/plugins/translations/server/index.ts b/x-pack/plugins/translations/server/index.ts index dfa3a2aa7211f..f15dc4cc730a7 100644 --- a/x-pack/plugins/translations/server/index.ts +++ b/x-pack/plugins/translations/server/index.ts @@ -15,4 +15,4 @@ class TranslationsPlugin { } } -export const plugin = () => new TranslationsPlugin(); +export const plugin = async () => new TranslationsPlugin(); diff --git a/x-pack/plugins/triggers_actions_ui/server/index.ts b/x-pack/plugins/triggers_actions_ui/server/index.ts index 2fb306e19402b..4dfe9a569a4bd 100644 --- a/x-pack/plugins/triggers_actions_ui/server/index.ts +++ b/x-pack/plugins/triggers_actions_ui/server/index.ts @@ -6,7 +6,6 @@ */ import { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core/server'; import { configSchema, ConfigSchema } from './config'; -import { TriggersActionsPlugin } from './plugin'; export type { PluginStartContract } from './plugin'; export type { TimeSeriesQuery, CoreQueryParams } from './data'; @@ -29,4 +28,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, }; -export const plugin = (ctx: PluginInitializerContext) => new TriggersActionsPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { TriggersActionsPlugin } = await import('./plugin'); + return new TriggersActionsPlugin(ctx); +}; diff --git a/x-pack/plugins/upgrade_assistant/server/index.ts b/x-pack/plugins/upgrade_assistant/server/index.ts index 976e7f58bffc7..589e2ced114ce 100644 --- a/x-pack/plugins/upgrade_assistant/server/index.ts +++ b/x-pack/plugins/upgrade_assistant/server/index.ts @@ -6,10 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { UpgradeAssistantServerPlugin } from './plugin'; export { config } from './config'; -export const plugin = (ctx: PluginInitializerContext) => { +export const plugin = async (ctx: PluginInitializerContext) => { + const { UpgradeAssistantServerPlugin } = await import('./plugin'); return new UpgradeAssistantServerPlugin(ctx); }; diff --git a/x-pack/plugins/uptime/server/index.ts b/x-pack/plugins/uptime/server/index.ts index 3ed326d1fc143..f1434bbd822dc 100644 --- a/x-pack/plugins/uptime/server/index.ts +++ b/x-pack/plugins/uptime/server/index.ts @@ -6,9 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { Plugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new Plugin(initializerContext); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { Plugin } = await import('./plugin'); + return new Plugin(initializerContext); +}; export { config } from '../common/config'; diff --git a/x-pack/plugins/ux/server/index.ts b/x-pack/plugins/ux/server/index.ts index e1027a9235eb3..911d24e465ed6 100644 --- a/x-pack/plugins/ux/server/index.ts +++ b/x-pack/plugins/ux/server/index.ts @@ -6,9 +6,10 @@ */ import { PluginInitializerContext } from '@kbn/core/server'; -import { Plugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => - new Plugin(); +export const plugin = async (initializerContext: PluginInitializerContext) => { + const { Plugin } = await import('./plugin'); + return new Plugin(); +}; export { config } from '../common/config'; diff --git a/x-pack/plugins/watcher/server/index.ts b/x-pack/plugins/watcher/server/index.ts index 42a76820f0c20..383316ce9a2ec 100644 --- a/x-pack/plugins/watcher/server/index.ts +++ b/x-pack/plugins/watcher/server/index.ts @@ -8,9 +8,10 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { offeringBasedSchema, schema } from '@kbn/config-schema'; -import { WatcherServerPlugin } from './plugin'; - -export const plugin = (ctx: PluginInitializerContext) => new WatcherServerPlugin(ctx); +export const plugin = async (ctx: PluginInitializerContext) => { + const { WatcherServerPlugin } = await import('./plugin'); + return new WatcherServerPlugin(ctx); +}; export const config = { schema: schema.object({ diff --git a/x-pack/test/alerting_api_integration/common/plugins/aad/server/index.ts b/x-pack/test/alerting_api_integration/common/plugins/aad/server/index.ts index 700aee6bfd49d..ed9e6682e0098 100644 --- a/x-pack/test/alerting_api_integration/common/plugins/aad/server/index.ts +++ b/x-pack/test/alerting_api_integration/common/plugins/aad/server/index.ts @@ -7,4 +7,4 @@ import { FixturePlugin } from './plugin'; -export const plugin = () => new FixturePlugin(); +export const plugin = async () => new FixturePlugin(); diff --git a/x-pack/test/alerting_api_integration/common/plugins/actions_simulators/server/index.ts b/x-pack/test/alerting_api_integration/common/plugins/actions_simulators/server/index.ts index 700aee6bfd49d..ed9e6682e0098 100644 --- a/x-pack/test/alerting_api_integration/common/plugins/actions_simulators/server/index.ts +++ b/x-pack/test/alerting_api_integration/common/plugins/actions_simulators/server/index.ts @@ -7,4 +7,4 @@ import { FixturePlugin } from './plugin'; -export const plugin = () => new FixturePlugin(); +export const plugin = async () => new FixturePlugin(); diff --git a/x-pack/test/alerting_api_integration/common/plugins/alerts/server/index.ts b/x-pack/test/alerting_api_integration/common/plugins/alerts/server/index.ts index 5a260b165f792..ed2682aacbf14 100644 --- a/x-pack/test/alerting_api_integration/common/plugins/alerts/server/index.ts +++ b/x-pack/test/alerting_api_integration/common/plugins/alerts/server/index.ts @@ -8,4 +8,5 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { FixturePlugin } from './plugin'; -export const plugin = (initContext: PluginInitializerContext) => new FixturePlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => + new FixturePlugin(initContext); diff --git a/x-pack/test/alerting_api_integration/common/plugins/alerts_restricted/server/index.ts b/x-pack/test/alerting_api_integration/common/plugins/alerts_restricted/server/index.ts index 700aee6bfd49d..ed9e6682e0098 100644 --- a/x-pack/test/alerting_api_integration/common/plugins/alerts_restricted/server/index.ts +++ b/x-pack/test/alerting_api_integration/common/plugins/alerts_restricted/server/index.ts @@ -7,4 +7,4 @@ import { FixturePlugin } from './plugin'; -export const plugin = () => new FixturePlugin(); +export const plugin = async () => new FixturePlugin(); diff --git a/x-pack/test/alerting_api_integration/common/plugins/task_manager_fixture/server/index.ts b/x-pack/test/alerting_api_integration/common/plugins/task_manager_fixture/server/index.ts index bed262d69ea18..9ef27eac56335 100644 --- a/x-pack/test/alerting_api_integration/common/plugins/task_manager_fixture/server/index.ts +++ b/x-pack/test/alerting_api_integration/common/plugins/task_manager_fixture/server/index.ts @@ -7,4 +7,4 @@ import { SampleTaskManagerFixturePlugin } from './plugin'; -export const plugin = () => new SampleTaskManagerFixturePlugin(); +export const plugin = async () => new SampleTaskManagerFixturePlugin(); diff --git a/x-pack/test/cases_api_integration/common/plugins/cases/server/index.ts b/x-pack/test/cases_api_integration/common/plugins/cases/server/index.ts index 50d0aa6df9b82..b84439c6851b0 100644 --- a/x-pack/test/cases_api_integration/common/plugins/cases/server/index.ts +++ b/x-pack/test/cases_api_integration/common/plugins/cases/server/index.ts @@ -8,5 +8,5 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { FixturePlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => +export const plugin = async (initializerContext: PluginInitializerContext) => new FixturePlugin(initializerContext); diff --git a/x-pack/test/cases_api_integration/common/plugins/observability/server/index.ts b/x-pack/test/cases_api_integration/common/plugins/observability/server/index.ts index 700aee6bfd49d..ed9e6682e0098 100644 --- a/x-pack/test/cases_api_integration/common/plugins/observability/server/index.ts +++ b/x-pack/test/cases_api_integration/common/plugins/observability/server/index.ts @@ -7,4 +7,4 @@ import { FixturePlugin } from './plugin'; -export const plugin = () => new FixturePlugin(); +export const plugin = async () => new FixturePlugin(); diff --git a/x-pack/test/cases_api_integration/common/plugins/security_solution/server/index.ts b/x-pack/test/cases_api_integration/common/plugins/security_solution/server/index.ts index 700aee6bfd49d..ed9e6682e0098 100644 --- a/x-pack/test/cases_api_integration/common/plugins/security_solution/server/index.ts +++ b/x-pack/test/cases_api_integration/common/plugins/security_solution/server/index.ts @@ -7,4 +7,4 @@ import { FixturePlugin } from './plugin'; -export const plugin = () => new FixturePlugin(); +export const plugin = async () => new FixturePlugin(); diff --git a/x-pack/test/cloud_integration/plugins/saml_provider/server/index.ts b/x-pack/test/cloud_integration/plugins/saml_provider/server/index.ts index ff490693e86a2..c0c10de01fb49 100644 --- a/x-pack/test/cloud_integration/plugins/saml_provider/server/index.ts +++ b/x-pack/test/cloud_integration/plugins/saml_provider/server/index.ts @@ -8,7 +8,7 @@ import { PluginInitializer, Plugin } from '@kbn/core/server'; import { initRoutes } from './init_routes'; -export const plugin: PluginInitializer = (): Plugin => ({ +export const plugin: PluginInitializer = async (): Promise => ({ setup: (core) => initRoutes(core), start: () => {}, stop: () => {}, diff --git a/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/index.ts b/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/index.ts index fec7965b88df4..c7d14986b6a14 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/index.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/index.ts @@ -48,7 +48,7 @@ export interface PluginsStart { spaces: never; } -export const plugin: PluginInitializer = () => ({ +export const plugin: PluginInitializer = async () => ({ setup(core: CoreSetup, deps: PluginsSetup) { for (const [name, namespaceType, hidden] of [ [SAVED_OBJECT_WITH_SECRET_TYPE, 'single', false], diff --git a/x-pack/test/functional_cors/plugins/kibana_cors_test/server/index.ts b/x-pack/test/functional_cors/plugins/kibana_cors_test/server/index.ts index 6412a3892660d..59b1414effa5d 100644 --- a/x-pack/test/functional_cors/plugins/kibana_cors_test/server/index.ts +++ b/x-pack/test/functional_cors/plugins/kibana_cors_test/server/index.ts @@ -9,7 +9,8 @@ import type { PluginConfigDescriptor, PluginInitializerContext } from '@kbn/core import { CorsTestPlugin } from './plugin'; import { configSchema, ConfigSchema } from './config'; -export const plugin = (initContext: PluginInitializerContext) => new CorsTestPlugin(initContext); +export const plugin = async (initContext: PluginInitializerContext) => + new CorsTestPlugin(initContext); export const config: PluginConfigDescriptor = { schema: configSchema, diff --git a/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts b/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts index 19c53e78c4876..8501a5920f76a 100644 --- a/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts +++ b/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts @@ -8,5 +8,5 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { IframeEmbeddedPlugin } from './plugin'; -export const plugin = (initContext: PluginInitializerContext) => +export const plugin = async (initContext: PluginInitializerContext) => new IframeEmbeddedPlugin(initContext); diff --git a/x-pack/test/functional_execution_context/plugins/alerts/server/index.ts b/x-pack/test/functional_execution_context/plugins/alerts/server/index.ts index dbd04e32e860b..0047ae70a993d 100644 --- a/x-pack/test/functional_execution_context/plugins/alerts/server/index.ts +++ b/x-pack/test/functional_execution_context/plugins/alerts/server/index.ts @@ -8,4 +8,4 @@ import './ensure_apm_started'; import { FixturePlugin } from './plugin'; -export const plugin = () => new FixturePlugin(); +export const plugin = async () => new FixturePlugin(); diff --git a/x-pack/test/functional_with_es_ssl/plugins/alerts/server/index.ts b/x-pack/test/functional_with_es_ssl/plugins/alerts/server/index.ts index b7c2aea144b5b..131cc04b22bf6 100644 --- a/x-pack/test/functional_with_es_ssl/plugins/alerts/server/index.ts +++ b/x-pack/test/functional_with_es_ssl/plugins/alerts/server/index.ts @@ -8,4 +8,4 @@ import { PluginInitializer } from '@kbn/core/server'; import { AlertingFixturePlugin } from './plugin'; -export const plugin: PluginInitializer = () => new AlertingFixturePlugin(); +export const plugin: PluginInitializer = async () => new AlertingFixturePlugin(); diff --git a/x-pack/test/functional_with_es_ssl/plugins/cases/server/index.ts b/x-pack/test/functional_with_es_ssl/plugins/cases/server/index.ts index df682115bd93a..ef145ab0ee92f 100644 --- a/x-pack/test/functional_with_es_ssl/plugins/cases/server/index.ts +++ b/x-pack/test/functional_with_es_ssl/plugins/cases/server/index.ts @@ -8,4 +8,4 @@ import { PluginInitializer } from '@kbn/core/server'; import { CasesFixturePlugin } from './plugin'; -export const plugin: PluginInitializer = () => new CasesFixturePlugin(); +export const plugin: PluginInitializer = async () => new CasesFixturePlugin(); diff --git a/x-pack/test/plugin_api_integration/plugins/elasticsearch_client/server/index.ts b/x-pack/test/plugin_api_integration/plugins/elasticsearch_client/server/index.ts index c101370938471..e95ccfe3eaa12 100644 --- a/x-pack/test/plugin_api_integration/plugins/elasticsearch_client/server/index.ts +++ b/x-pack/test/plugin_api_integration/plugins/elasticsearch_client/server/index.ts @@ -7,4 +7,4 @@ import { ElasticsearchClientXPack } from './plugin'; -export const plugin = () => new ElasticsearchClientXPack(); +export const plugin = async () => new ElasticsearchClientXPack(); diff --git a/x-pack/test/plugin_api_integration/plugins/event_log/server/index.ts b/x-pack/test/plugin_api_integration/plugins/event_log/server/index.ts index eb8bfa1b80cff..24c0958a58488 100644 --- a/x-pack/test/plugin_api_integration/plugins/event_log/server/index.ts +++ b/x-pack/test/plugin_api_integration/plugins/event_log/server/index.ts @@ -8,5 +8,5 @@ import { PluginInitializerContext } from '@kbn/core/server'; import { EventLogFixturePlugin } from './plugin'; -export const plugin = (initContext: PluginInitializerContext) => +export const plugin = async (initContext: PluginInitializerContext) => new EventLogFixturePlugin(initContext); diff --git a/x-pack/test/plugin_api_integration/plugins/feature_usage_test/server/index.ts b/x-pack/test/plugin_api_integration/plugins/feature_usage_test/server/index.ts index b649fbc808272..6d0e1606f0044 100644 --- a/x-pack/test/plugin_api_integration/plugins/feature_usage_test/server/index.ts +++ b/x-pack/test/plugin_api_integration/plugins/feature_usage_test/server/index.ts @@ -15,4 +15,4 @@ import { export const plugin: PluginInitializer< FeatureUsageTestPluginSetup, FeatureUsageTestPluginStart -> = () => new FeatureUsageTestPlugin(); +> = async () => new FeatureUsageTestPlugin(); diff --git a/x-pack/test/plugin_api_integration/plugins/sample_task_plugin/server/index.ts b/x-pack/test/plugin_api_integration/plugins/sample_task_plugin/server/index.ts index bed262d69ea18..9ef27eac56335 100644 --- a/x-pack/test/plugin_api_integration/plugins/sample_task_plugin/server/index.ts +++ b/x-pack/test/plugin_api_integration/plugins/sample_task_plugin/server/index.ts @@ -7,4 +7,4 @@ import { SampleTaskManagerFixturePlugin } from './plugin'; -export const plugin = () => new SampleTaskManagerFixturePlugin(); +export const plugin = async () => new SampleTaskManagerFixturePlugin(); diff --git a/x-pack/test/plugin_api_perf/plugins/task_manager_performance/server/index.ts b/x-pack/test/plugin_api_perf/plugins/task_manager_performance/server/index.ts index bed262d69ea18..9ef27eac56335 100644 --- a/x-pack/test/plugin_api_perf/plugins/task_manager_performance/server/index.ts +++ b/x-pack/test/plugin_api_perf/plugins/task_manager_performance/server/index.ts @@ -7,4 +7,4 @@ import { SampleTaskManagerFixturePlugin } from './plugin'; -export const plugin = () => new SampleTaskManagerFixturePlugin(); +export const plugin = async () => new SampleTaskManagerFixturePlugin(); diff --git a/x-pack/test/saved_object_api_integration/common/plugins/saved_object_test_plugin/server/index.ts b/x-pack/test/saved_object_api_integration/common/plugins/saved_object_test_plugin/server/index.ts index 1db5fe493b35b..e30ef09b951ee 100644 --- a/x-pack/test/saved_object_api_integration/common/plugins/saved_object_test_plugin/server/index.ts +++ b/x-pack/test/saved_object_api_integration/common/plugins/saved_object_test_plugin/server/index.ts @@ -7,6 +7,6 @@ import { Plugin } from './plugin'; -export function plugin() { +export async function plugin() { return new Plugin(); } diff --git a/x-pack/test/security_api_integration/plugins/audit_log/server/index.ts b/x-pack/test/security_api_integration/plugins/audit_log/server/index.ts index 7328c41ac6d1a..342396a8cde4b 100644 --- a/x-pack/test/security_api_integration/plugins/audit_log/server/index.ts +++ b/x-pack/test/security_api_integration/plugins/audit_log/server/index.ts @@ -7,4 +7,4 @@ import { AuditTrailTestPlugin } from './plugin'; -export const plugin = () => new AuditTrailTestPlugin(); +export const plugin = async () => new AuditTrailTestPlugin(); diff --git a/x-pack/test/security_api_integration/plugins/oidc_provider/server/index.ts b/x-pack/test/security_api_integration/plugins/oidc_provider/server/index.ts index b5a6123de4398..82e460a6a4c27 100644 --- a/x-pack/test/security_api_integration/plugins/oidc_provider/server/index.ts +++ b/x-pack/test/security_api_integration/plugins/oidc_provider/server/index.ts @@ -8,7 +8,7 @@ import type { PluginInitializer, Plugin } from '@kbn/core/server'; import { initRoutes } from './init_routes'; -export const plugin: PluginInitializer = (): Plugin => ({ +export const plugin: PluginInitializer = async (): Promise => ({ setup: (core) => initRoutes(core.http.createRouter()), start: () => {}, stop: () => {}, diff --git a/x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts b/x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts index 5558cceea2572..9a5efa5fa6861 100644 --- a/x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts +++ b/x-pack/test/security_api_integration/plugins/saml_provider/server/index.ts @@ -8,7 +8,7 @@ import type { PluginInitializer, Plugin } from '@kbn/core/server'; import { initRoutes } from './init_routes'; -export const plugin: PluginInitializer = (): Plugin => ({ +export const plugin: PluginInitializer = async (): Promise => ({ setup: (core) => initRoutes(core), start: () => {}, stop: () => {}, diff --git a/x-pack/test/security_api_integration/plugins/user_profiles_consumer/server/index.ts b/x-pack/test/security_api_integration/plugins/user_profiles_consumer/server/index.ts index 9467c7b4358b4..7cd8187558a88 100644 --- a/x-pack/test/security_api_integration/plugins/user_profiles_consumer/server/index.ts +++ b/x-pack/test/security_api_integration/plugins/user_profiles_consumer/server/index.ts @@ -26,11 +26,8 @@ export interface PluginStartDependencies { spaces: SpacesPluginStart; } -export const plugin: PluginInitializer = (): Plugin< - void, - void, - PluginSetupDependencies, - PluginStartDependencies +export const plugin: PluginInitializer = async (): Promise< + Plugin > => ({ setup: (core: CoreSetup) => initRoutes(core), start: () => {}, diff --git a/x-pack/test/security_functional/plugins/test_endpoints/server/index.ts b/x-pack/test/security_functional/plugins/test_endpoints/server/index.ts index 33ce96a3cfffa..38ad79b213218 100644 --- a/x-pack/test/security_functional/plugins/test_endpoints/server/index.ts +++ b/x-pack/test/security_functional/plugins/test_endpoints/server/index.ts @@ -20,9 +20,9 @@ export interface PluginStartDependencies { taskManager: TaskManagerStartContract; } -export const plugin: PluginInitializer = ( +export const plugin: PluginInitializer = async ( initializerContext -): Plugin => ({ +): Promise> => ({ setup: (core: CoreSetup) => initRoutes(initializerContext, core), start: () => {}, stop: () => {}, diff --git a/x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin/server/index.ts b/x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin/server/index.ts index 1db5fe493b35b..e30ef09b951ee 100644 --- a/x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin/server/index.ts +++ b/x-pack/test/spaces_api_integration/common/plugins/spaces_test_plugin/server/index.ts @@ -7,6 +7,6 @@ import { Plugin } from './plugin'; -export function plugin() { +export async function plugin() { return new Plugin(); } diff --git a/x-pack/test/ui_capabilities/common/plugins/foo_plugin/server/index.ts b/x-pack/test/ui_capabilities/common/plugins/foo_plugin/server/index.ts index 7bb8b446dcc79..4698b8c59c8f4 100644 --- a/x-pack/test/ui_capabilities/common/plugins/foo_plugin/server/index.ts +++ b/x-pack/test/ui_capabilities/common/plugins/foo_plugin/server/index.ts @@ -8,7 +8,7 @@ import { CoreSetup, Plugin } from '@kbn/core/server'; import { PluginSetupContract as FeaturesPluginSetupContract } from '@kbn/features-plugin/server'; -export const plugin = () => new FooPlugin(); +export const plugin = async () => new FooPlugin(); interface SetupDeps { features: FeaturesPluginSetupContract; From 583d1fd6fb86b4936c3fd7cb9d4392729da238b7 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:59:18 +0000 Subject: [PATCH 02/12] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- src/plugins/maps_ems/tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/maps_ems/tsconfig.json b/src/plugins/maps_ems/tsconfig.json index 7d32dacb6d55a..e8ed41cf54f36 100644 --- a/src/plugins/maps_ems/tsconfig.json +++ b/src/plugins/maps_ems/tsconfig.json @@ -11,6 +11,8 @@ "@kbn/config-schema", "@kbn/config", "@kbn/core-http-common", + "@kbn/core-plugins-server", + "@kbn/core-lifecycle-server", ], "exclude": [ "target/**/*", From ff319065c6c67c8a6a268843ba62d7ed31d0f820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 9 Nov 2023 09:13:10 +0100 Subject: [PATCH 03/12] Revert browser-side types --- .../plugins/core-plugins-browser/src/plugin_initializer.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts b/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts index 8f672c7213c32..c33abbfc386f9 100644 --- a/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts +++ b/packages/core/plugins/core-plugins-browser/src/plugin_initializer.ts @@ -22,9 +22,7 @@ export type PluginInitializer< TStart, TPluginsSetup extends object = object, TPluginsStart extends object = object -> = ( - core: PluginInitializerContext -) => Promise>; +> = (core: PluginInitializerContext) => Plugin; /** * The available core services passed to a `PluginInitializer` From faaa57aaa253708d3c8c170e7a56155e0c4eb167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 9 Nov 2023 09:28:20 +0100 Subject: [PATCH 04/12] Fix unit tests --- .../src/plugin.test.ts | 66 ++++++++++++------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugin.test.ts b/packages/core/plugins/core-plugins-server-internal/src/plugin.test.ts index 5b11139397a12..128c674753129 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugin.test.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugin.test.ts @@ -157,7 +157,7 @@ describe('`constructor` correctly sets non-external source', () => { }); }); -test('`setup` fails if `plugin` initializer is not exported', () => { +test('`setup` fails if the plugin has not been initialized', () => { const manifest = createPluginManifest(); const opaqueId = Symbol(); const plugin = new PluginWrapper({ @@ -176,11 +176,32 @@ test('`setup` fails if `plugin` initializer is not exported', () => { expect(() => plugin.setup(createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }), {}) ).toThrowErrorMatchingInlineSnapshot( + `"The plugin is not initialized. Call the init method first."` + ); +}); + +test('`init` fails if `plugin` initializer is not exported', async () => { + const manifest = createPluginManifest(); + const opaqueId = Symbol(); + const plugin = new PluginWrapper({ + path: 'plugin-without-initializer-path', + manifest, + opaqueId, + initializerContext: createPluginInitializerContext({ + coreContext, + opaqueId, + manifest, + instanceInfo, + nodeInfo, + }), + }); + + await expect(() => plugin.init()).rejects.toThrowErrorMatchingInlineSnapshot( `"Plugin \\"some-plugin-id\\" does not export \\"plugin\\" definition (plugin-without-initializer-path)."` ); }); -test('`setup` fails if plugin initializer is not a function', () => { +test('`init` fails if plugin initializer is not a function', async () => { const manifest = createPluginManifest(); const opaqueId = Symbol(); const plugin = new PluginWrapper({ @@ -196,14 +217,12 @@ test('`setup` fails if plugin initializer is not a function', () => { }), }); - expect(() => - plugin.setup(createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }), {}) - ).toThrowErrorMatchingInlineSnapshot( + await expect(() => plugin.init()).rejects.toThrowErrorMatchingInlineSnapshot( `"Definition of plugin \\"some-plugin-id\\" should be a function (plugin-with-wrong-initializer-path)."` ); }); -test('`setup` fails if initializer does not return object', () => { +test('`init` fails if initializer does not return object', async () => { const manifest = createPluginManifest(); const opaqueId = Symbol(); const plugin = new PluginWrapper({ @@ -219,16 +238,14 @@ test('`setup` fails if initializer does not return object', () => { }), }); - mockPluginInitializer.mockReturnValue(null); + mockPluginInitializer.mockResolvedValue(null); - expect(() => - plugin.setup(createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }), {}) - ).toThrowErrorMatchingInlineSnapshot( + await expect(() => plugin.init()).rejects.toThrowErrorMatchingInlineSnapshot( `"Initializer for plugin \\"some-plugin-id\\" is expected to return plugin instance, but returned \\"null\\"."` ); }); -test('`setup` fails if object returned from initializer does not define `setup` function', () => { +test('`init` fails if object returned from initializer does not define `setup` function', async () => { const manifest = createPluginManifest(); const opaqueId = Symbol(); const plugin = new PluginWrapper({ @@ -245,11 +262,9 @@ test('`setup` fails if object returned from initializer does not define `setup` }); const mockPluginInstance = { run: jest.fn() }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); - expect(() => - plugin.setup(createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }), {}) - ).toThrowErrorMatchingInlineSnapshot( + await expect(() => plugin.init()).rejects.toThrowErrorMatchingInlineSnapshot( `"Instance of plugin \\"some-plugin-id\\" does not define \\"setup\\" function."` ); }); @@ -272,7 +287,9 @@ test('`setup` initializes plugin and calls appropriate lifecycle hook', async () }); const mockPluginInstance = { setup: jest.fn().mockResolvedValue({ contract: 'yes' }) }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); + + await plugin.init(); const setupContext = createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }); const setupDependencies = { 'some-required-dep': { contract: 'no' } }; @@ -323,8 +340,9 @@ test('`start` fails invoked for the `preboot` plugin', async () => { }); const mockPluginInstance = { setup: jest.fn() }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); + await plugin.init(); await plugin.setup({} as any, {} as any); expect(() => plugin.start({} as any, {} as any)).toThrowErrorMatchingInlineSnapshot( @@ -355,8 +373,9 @@ test('`start` calls plugin.start with context and dependencies', async () => { setup: jest.fn(), start: jest.fn().mockResolvedValue(pluginStartContract), }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); + await plugin.init(); await plugin.setup({} as any, {} as any); const startContract = await plugin.start(context, deps); @@ -399,8 +418,9 @@ test("`start` resolves `startDependencies` Promise after plugin's start", async return pluginStartContract; }, }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); + await plugin.init(); await plugin.setup({} as any, {} as any); const startDependenciesCheck = plugin.startDependencies.then((resolvedStartDeps) => { @@ -429,7 +449,7 @@ test('`stop` fails if plugin is not set up', async () => { }); const mockPluginInstance = { setup: jest.fn(), stop: jest.fn() }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); await expect(plugin.stop()).rejects.toMatchInlineSnapshot( `[Error: Plugin "some-plugin-id" can't be stopped since it isn't set up.]` @@ -453,7 +473,8 @@ test('`stop` does nothing if plugin does not define `stop` function', async () = }), }); - mockPluginInitializer.mockReturnValue({ setup: jest.fn() }); + mockPluginInitializer.mockResolvedValue({ setup: jest.fn() }); + await plugin.init(); await plugin.setup(createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }), {}); await expect(plugin.stop()).resolves.toBeUndefined(); @@ -476,7 +497,8 @@ test('`stop` calls `stop` defined by the plugin instance', async () => { }); const mockPluginInstance = { setup: jest.fn(), stop: jest.fn() }; - mockPluginInitializer.mockReturnValue(mockPluginInstance); + mockPluginInitializer.mockResolvedValue(mockPluginInstance); + await plugin.init(); await plugin.setup(createPluginSetupContext({ deps: setupDeps, plugin, runtimeResolver }), {}); await expect(plugin.stop()).resolves.toBeUndefined(); From 56c9f7633333a23acd4650e5aed7a2cfe6c4e45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 9 Nov 2023 10:18:48 +0100 Subject: [PATCH 05/12] Fix mocks --- src/plugins/bfetch/server/mocks.ts | 2 +- src/plugins/expressions/server/mocks.ts | 2 +- src/plugins/kibana_usage_collection/server/plugin.test.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/bfetch/server/mocks.ts b/src/plugins/bfetch/server/mocks.ts index d1be681dd407f..4fb5d1ea8eb58 100644 --- a/src/plugins/bfetch/server/mocks.ts +++ b/src/plugins/bfetch/server/mocks.ts @@ -31,7 +31,7 @@ const createPlugin = async () => { const pluginInitializerContext = coreMock.createPluginInitializerContext(); const coreSetup = coreMock.createSetup(); const coreStart = coreMock.createStart(); - const plugin = pluginInitializer(pluginInitializerContext); + const plugin = await pluginInitializer(pluginInitializerContext); const setup = await plugin.setup(coreSetup, {}); return { diff --git a/src/plugins/expressions/server/mocks.ts b/src/plugins/expressions/server/mocks.ts index df5232ab5faf5..db6348d1d3fe9 100644 --- a/src/plugins/expressions/server/mocks.ts +++ b/src/plugins/expressions/server/mocks.ts @@ -41,7 +41,7 @@ const createPlugin = async () => { const pluginInitializerContext = coreMock.createPluginInitializerContext(); const coreSetup = coreMock.createSetup(); const coreStart = coreMock.createStart(); - const plugin = pluginInitializer(pluginInitializerContext); + const plugin = await pluginInitializer(pluginInitializerContext); const setup = await plugin.setup(coreSetup); return { diff --git a/src/plugins/kibana_usage_collection/server/plugin.test.ts b/src/plugins/kibana_usage_collection/server/plugin.test.ts index ef26492c2d6fd..47bc41c4e1fcf 100644 --- a/src/plugins/kibana_usage_collection/server/plugin.test.ts +++ b/src/plugins/kibana_usage_collection/server/plugin.test.ts @@ -17,9 +17,10 @@ import { } from '@kbn/usage-collection-plugin/server/mocks'; import { cloudDetailsMock, registerEbtCountersMock } from './plugin.test.mocks'; import { plugin } from '.'; +import type { KibanaUsageCollectionPlugin } from './plugin'; describe('kibana_usage_collection', () => { - const pluginInstance = plugin(coreMock.createPluginInitializerContext({})); + let pluginInstance: KibanaUsageCollectionPlugin; const usageCollectors: CollectorOptions[] = []; @@ -33,7 +34,8 @@ describe('kibana_usage_collection', () => { return createUsageCollectionSetupMock().makeStatsCollector(opts); }); - beforeEach(() => { + beforeEach(async () => { + pluginInstance = await plugin(coreMock.createPluginInitializerContext({})); cloudDetailsMock.mockClear(); }); From 277d10561b90c2c28d3b77efa9da1af2b78d380a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 9 Nov 2023 17:45:06 +0100 Subject: [PATCH 06/12] Fix x-pack/examples --- x-pack/examples/alerting_example/server/index.ts | 6 ++++-- .../gen_ai_streaming_response_example/server/index.ts | 7 ++++--- x-pack/examples/screenshotting_example/server/index.ts | 5 ++--- .../examples/third_party_vis_lens_example/server/index.ts | 6 ++++-- x-pack/plugins/screenshotting/server/index.ts | 6 +++--- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/x-pack/examples/alerting_example/server/index.ts b/x-pack/examples/alerting_example/server/index.ts index f14bbe1baac9d..0dbe94868f43a 100644 --- a/x-pack/examples/alerting_example/server/index.ts +++ b/x-pack/examples/alerting_example/server/index.ts @@ -6,6 +6,8 @@ */ import { PluginInitializer } from '@kbn/core/server'; -import { AlertingExamplePlugin } from './plugin'; -export const plugin: PluginInitializer = () => new AlertingExamplePlugin(); +export const plugin: PluginInitializer = async () => { + const { AlertingExamplePlugin } = await import('./plugin'); + return new AlertingExamplePlugin(); +}; diff --git a/x-pack/examples/gen_ai_streaming_response_example/server/index.ts b/x-pack/examples/gen_ai_streaming_response_example/server/index.ts index e85214a01d03d..e745ea8f51c6c 100644 --- a/x-pack/examples/gen_ai_streaming_response_example/server/index.ts +++ b/x-pack/examples/gen_ai_streaming_response_example/server/index.ts @@ -6,7 +6,8 @@ */ import { PluginInitializer } from '@kbn/core/server'; -import { GenAiStreamingResponseExamplePlugin } from './plugin'; -export const plugin: PluginInitializer = () => - new GenAiStreamingResponseExamplePlugin(); +export const plugin: PluginInitializer = async () => { + const { GenAiStreamingResponseExamplePlugin } = await import('./plugin'); + return new GenAiStreamingResponseExamplePlugin(); +}; diff --git a/x-pack/examples/screenshotting_example/server/index.ts b/x-pack/examples/screenshotting_example/server/index.ts index 2d9a1d5fbb25b..a1354eee59af9 100644 --- a/x-pack/examples/screenshotting_example/server/index.ts +++ b/x-pack/examples/screenshotting_example/server/index.ts @@ -5,8 +5,7 @@ * 2.0. */ -import { ScreenshottingExamplePlugin } from './plugin'; - -export function plugin() { +export async function plugin() { + const { ScreenshottingExamplePlugin } = await import('./plugin'); return new ScreenshottingExamplePlugin(); } diff --git a/x-pack/examples/third_party_vis_lens_example/server/index.ts b/x-pack/examples/third_party_vis_lens_example/server/index.ts index cba785e2c3783..ea57af5d4e327 100644 --- a/x-pack/examples/third_party_vis_lens_example/server/index.ts +++ b/x-pack/examples/third_party_vis_lens_example/server/index.ts @@ -6,6 +6,8 @@ */ import { PluginInitializer } from '@kbn/core/server'; -import { ThirdPartyVisLensExamplePlugin } from './plugin'; -export const plugin: PluginInitializer = () => new ThirdPartyVisLensExamplePlugin(); +export const plugin: PluginInitializer = async () => { + const { ThirdPartyVisLensExamplePlugin } = await import('./plugin'); + return new ThirdPartyVisLensExamplePlugin(); +}; diff --git a/x-pack/plugins/screenshotting/server/index.ts b/x-pack/plugins/screenshotting/server/index.ts index c5755d93ebd1f..414fde21c85a9 100755 --- a/x-pack/plugins/screenshotting/server/index.ts +++ b/x-pack/plugins/screenshotting/server/index.ts @@ -5,14 +5,14 @@ * 2.0. */ -import type { ScreenshottingPlugin } from './plugin'; +import { PluginInitializerContext } from '@kbn/core-plugins-server'; /** * Screenshotting plugin entry point. */ -export async function plugin(...args: ConstructorParameters) { +export async function plugin(pluginInitializerContext: PluginInitializerContext) { const { ScreenshottingPlugin } = await import('./plugin'); - return new ScreenshottingPlugin(...args); + return new ScreenshottingPlugin(pluginInitializerContext); } export { config } from './config'; From 74a2dadedbdcce0ef6423be51ced136d470d6733 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:54:24 +0000 Subject: [PATCH 07/12] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/screenshotting/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/screenshotting/tsconfig.json b/x-pack/plugins/screenshotting/tsconfig.json index 3749a60fc4fe4..f23b380911f0f 100644 --- a/x-pack/plugins/screenshotting/tsconfig.json +++ b/x-pack/plugins/screenshotting/tsconfig.json @@ -25,6 +25,7 @@ "@kbn/core-logging-server-mocks", "@kbn/logging-mocks", "@kbn/core-http-server", + "@kbn/core-plugins-server", ], "exclude": [ "target/**/*", From 4331b38e34e0df84dddb5925ae5d7b2290a7e2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 10 Nov 2023 08:58:55 +0100 Subject: [PATCH 08/12] Fix jest tests --- .../src/plugins_system.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/plugins/core-plugins-server-internal/src/plugins_system.test.ts b/packages/core/plugins/core-plugins-server-internal/src/plugins_system.test.ts index 42ea7012745f2..5406b60cb09e8 100644 --- a/packages/core/plugins/core-plugins-server-internal/src/plugins_system.test.ts +++ b/packages/core/plugins/core-plugins-server-internal/src/plugins_system.test.ts @@ -43,7 +43,7 @@ function createPlugin( type?: PluginType; } = {} ): PluginWrapper { - return new PluginWrapper({ + const plugin = new PluginWrapper({ path: 'some-path', manifest: { id, @@ -62,6 +62,8 @@ function createPlugin( opaqueId: Symbol(id), initializerContext: { logger } as any, }); + jest.spyOn(plugin, 'init').mockResolvedValue(); + return plugin; } const prebootDeps = coreInternalLifecycleMock.createInternalPreboot(); @@ -602,7 +604,10 @@ describe('setup', () => { mockCreatePluginSetupContext.mockImplementation(() => ({})); const promise = pluginsSystem.setupPlugins(setupDeps); - jest.runAllTimers(); + process.nextTick(() => { + // let the await init go through. then simulate the timeout + jest.runAllTimers(); + }); await expect(promise).rejects.toMatchInlineSnapshot( `[Error: Setup lifecycle of "timeout-setup" plugin wasn't completed in 10sec. Consider disabling the plugin and re-start.]` From 862e41e977aa978516e50f94895d0a619f3a3db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 10 Nov 2023 09:15:09 +0100 Subject: [PATCH 09/12] Revert changes in `/public/` --- src/plugins/saved_objects/public/index.ts | 2 +- x-pack/plugins/serverless_search/public/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/saved_objects/public/index.ts b/src/plugins/saved_objects/public/index.ts index d343addcdcda1..a159c3278f0b9 100644 --- a/src/plugins/saved_objects/public/index.ts +++ b/src/plugins/saved_objects/public/index.ts @@ -19,4 +19,4 @@ export { checkForDuplicateTitle, saveWithConfirmation, isErrorNonFatal } from '. export type { SavedObjectSaveOpts, SavedObject, SavedObjectConfig } from './types'; export type { SavedObjectsStart, SavedObjectSetup } from './plugin'; -export const plugin = async () => new SavedObjectsPublicPlugin(); +export const plugin = () => new SavedObjectsPublicPlugin(); diff --git a/x-pack/plugins/serverless_search/public/index.ts b/x-pack/plugins/serverless_search/public/index.ts index c645efab33e37..a0f2c3c6eceb9 100644 --- a/x-pack/plugins/serverless_search/public/index.ts +++ b/x-pack/plugins/serverless_search/public/index.ts @@ -4,11 +4,11 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { ServerlessSearchPlugin } from './plugin'; // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. -export async function plugin() { - const { ServerlessSearchPlugin } = await import('./plugin'); +export function plugin() { return new ServerlessSearchPlugin(); } From 27903872aafee588c0e89f3b96f7b031376b6d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 10 Nov 2023 10:58:45 +0100 Subject: [PATCH 10/12] Fix another jest test --- src/plugins/kibana_usage_collection/server/plugin.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/kibana_usage_collection/server/plugin.test.ts b/src/plugins/kibana_usage_collection/server/plugin.test.ts index 47bc41c4e1fcf..a798eaa5aa1df 100644 --- a/src/plugins/kibana_usage_collection/server/plugin.test.ts +++ b/src/plugins/kibana_usage_collection/server/plugin.test.ts @@ -34,8 +34,11 @@ describe('kibana_usage_collection', () => { return createUsageCollectionSetupMock().makeStatsCollector(opts); }); - beforeEach(async () => { + beforeAll(async () => { pluginInstance = await plugin(coreMock.createPluginInitializerContext({})); + }); + + beforeEach(() => { cloudDetailsMock.mockClear(); }); From 0404c340762a677e5a3601f61b69db407eb6062e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 10 Nov 2023 13:02:36 +0100 Subject: [PATCH 11/12] HTTP Status FTRs should wait for Kibana to accept requests --- test/server_integration/http/platform/config.status.ts | 3 ++- test/server_integration/http/platform/status.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/server_integration/http/platform/config.status.ts b/test/server_integration/http/platform/config.status.ts index 638d850a8f75c..53ff1e609f689 100644 --- a/test/server_integration/http/platform/config.status.ts +++ b/test/server_integration/http/platform/config.status.ts @@ -40,7 +40,8 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { runOptions: { ...httpConfig.get('kbnTestServer.runOptions'), // Don't wait for Kibana to be completely ready so that we can test the status timeouts - wait: /Kibana is now unavailable/, + // but wait for http service to listen. + wait: /\[http\.server\.Kibana\] http server running at/, alwaysUseSource: true, }, }, diff --git a/test/server_integration/http/platform/status.ts b/test/server_integration/http/platform/status.ts index 50c136bfa1027..8ce193c670849 100644 --- a/test/server_integration/http/platform/status.ts +++ b/test/server_integration/http/platform/status.ts @@ -32,7 +32,7 @@ export default function ({ getService }: FtrProviderContext) { .expect(200); describe('status service', () => { - // This test must comes first because the timeout only applies to the initial emission + // This test must come first because the timeout only applies to the initial emission it("returns a timeout for status check that doesn't emit after 30s", async () => { let aStatus = await getStatus('statusPluginA'); expect(aStatus.level).to.eql('unavailable'); From a7038ae96e891b9dde49b89bd74da94e50c909c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 10 Nov 2023 21:52:09 +0100 Subject: [PATCH 12/12] Add docs + generator changes --- dev_docs/key_concepts/anatomy_of_a_plugin.mdx | 13 +++++++++++-- .../core/configuration-service.asciidoc | 2 +- .../kibana-platform-plugin-api.asciidoc | 4 ++-- .../template/server/index.ts.ejs | 5 ++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/dev_docs/key_concepts/anatomy_of_a_plugin.mdx b/dev_docs/key_concepts/anatomy_of_a_plugin.mdx index c71897fc34fcb..6b90fa0b0c938 100644 --- a/dev_docs/key_concepts/anatomy_of_a_plugin.mdx +++ b/dev_docs/key_concepts/anatomy_of_a_plugin.mdx @@ -122,7 +122,7 @@ If you are developing in TypeScript (which we recommend), you will need to add a core capabilities as an argument. It should return an instance of its plugin class for Kibana to load. ```ts -import type { PluginInitializerContext } from '@kbn/core/server'; +import type { PluginInitializerContext } from '@kbn/core/public'; import { DemoPlugin } from './plugin'; export function plugin(initializerContext: PluginInitializerContext) { @@ -177,7 +177,16 @@ export class DemoPlugin implements Plugin { ### server/index.ts -`server/index.ts` is the entry-point into the server-side code of this plugin. It is identical in almost every way to the client-side entry-point: +`server/index.ts` is the entry-point into the server-side code of this plugin. + +```ts +import type { PluginInitializerContext } from '@kbn/core/server'; + +export async function plugin(initializerContext: PluginInitializerContext) { + const { DemoPlugin } = await import('./plugin'); + return new DemoPlugin(initializerContext); +} +``` ### server/plugin.ts diff --git a/docs/developer/architecture/core/configuration-service.asciidoc b/docs/developer/architecture/core/configuration-service.asciidoc index ed03be73296cb..86c4d5050b0b9 100644 --- a/docs/developer/architecture/core/configuration-service.asciidoc +++ b/docs/developer/architecture/core/configuration-service.asciidoc @@ -35,7 +35,7 @@ export type MyPluginConfigType = TypeOf; * Read config value exposed via `PluginInitializerContext`: -*my_plugin/server/index.ts* +*my_plugin/server/plugin.ts* [source,typescript] ---- import type { PluginInitializerContext } from '@kbn/core/server'; diff --git a/docs/developer/architecture/kibana-platform-plugin-api.asciidoc b/docs/developer/architecture/kibana-platform-plugin-api.asciidoc index 85fc05d0f9fd8..4c23aead9d566 100644 --- a/docs/developer/architecture/kibana-platform-plugin-api.asciidoc +++ b/docs/developer/architecture/kibana-platform-plugin-api.asciidoc @@ -100,9 +100,9 @@ entry-point: [source,typescript] ---- import type { PluginInitializerContext } from '@kbn/core/server'; -import { MyPlugin } from './plugin'; -export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { MyPlugin } = await import('./plugin'); return new MyPlugin(initializerContext); } ---- diff --git a/packages/kbn-plugin-generator/template/server/index.ts.ejs b/packages/kbn-plugin-generator/template/server/index.ts.ejs index 5e0510b7ecb86..68cce4a2157c9 100644 --- a/packages/kbn-plugin-generator/template/server/index.ts.ejs +++ b/packages/kbn-plugin-generator/template/server/index.ts.ejs @@ -1,11 +1,10 @@ import { PluginInitializerContext } from '<%= importFromRoot('src/core/server') %>'; -import { <%= upperCamelCase(name) %>Plugin } from './plugin'; - // This exports static code and TypeScript types, // as well as, Kibana Platform `plugin()` initializer. - export function plugin(initializerContext: PluginInitializerContext) { +export async function plugin(initializerContext: PluginInitializerContext) { + const { <%= upperCamelCase(name) %>Plugin } = await import('./plugin'); return new <%= upperCamelCase(name) %>Plugin(initializerContext); }