From 4974e8528636ff3539e40aa04de699d76fb011a0 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 29 Apr 2020 13:57:43 +0100 Subject: [PATCH] Revert "chore(NA): add async import into infra plugin to reduce apm bundle size (#63292)" This reverts commit 30439f6df0778582e53a6d51ec5f2b2f9885697f. --- x-pack/plugins/infra/public/plugin.ts | 29 +++++---------------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/x-pack/plugins/infra/public/plugin.ts b/x-pack/plugins/infra/public/plugin.ts index 26f206c06203b..40366b2a54f24 100644 --- a/x-pack/plugins/infra/public/plugin.ts +++ b/x-pack/plugins/infra/public/plugin.ts @@ -21,6 +21,8 @@ import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/p import { DataEnhancedSetup, DataEnhancedStart } from '../../data_enhanced/public'; import { TriggersAndActionsUIPublicPluginSetup } from '../../../plugins/triggers_actions_ui/public'; +import { getAlertType as getMetricsAlertType } from './components/alerting/metrics/metric_threshold_alert_type'; +import { getAlertType as getLogsAlertType } from './components/alerting/logs/log_threshold_alert_type'; export type ClientSetup = void; export type ClientStart = void; @@ -51,6 +53,9 @@ export class Plugin setup(core: CoreSetup, pluginsSetup: ClientPluginsSetup) { registerFeatures(pluginsSetup.home); + pluginsSetup.triggers_actions_ui.alertTypeRegistry.register(getMetricsAlertType()); + pluginsSetup.triggers_actions_ui.alertTypeRegistry.register(getLogsAlertType()); + core.application.register({ id: 'logs', title: i18n.translate('xpack.infra.logs.pluginTitle', { @@ -65,8 +70,6 @@ export class Plugin const plugins = getMergedPlugins(pluginsSetup, pluginsStart as ClientPluginsStart); const { startApp, composeLibs, LogsRouter } = await this.downloadAssets(); - await this.registerLogsAlertType(pluginsSetup); - return startApp( composeLibs(coreStart), coreStart, @@ -92,8 +95,6 @@ export class Plugin const plugins = getMergedPlugins(pluginsSetup, pluginsStart as ClientPluginsStart); const { startApp, composeLibs, MetricsRouter } = await this.downloadAssets(); - await this.registerMetricsAlertType(pluginsSetup); - return startApp( composeLibs(coreStart), coreStart, @@ -137,24 +138,4 @@ export class Plugin MetricsRouter, }; } - - // NOTE: apm is importing from `infra/public` and async importing that - // allow us to reduce the apm bundle size - private async registerLogsAlertType(pluginsSetup: ClientPluginsSetup) { - const { getAlertType } = await import('./components/alerting/logs/log_threshold_alert_type'); - - if (!pluginsSetup.triggers_actions_ui.alertTypeRegistry.has(getAlertType().id)) { - pluginsSetup.triggers_actions_ui.alertTypeRegistry.register(getAlertType()); - } - } - - private async registerMetricsAlertType(pluginsSetup: ClientPluginsSetup) { - const { getAlertType } = await import( - './components/alerting/metrics/metric_threshold_alert_type' - ); - - if (!pluginsSetup.triggers_actions_ui.alertTypeRegistry.has(getAlertType().id)) { - pluginsSetup.triggers_actions_ui.alertTypeRegistry.register(getAlertType()); - } - } }