From 7caf108a9df3f087d4d65d9b54f8dc25c574af16 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 15 Feb 2021 11:59:30 +0100 Subject: [PATCH] [ML] Fix imports for lazy loadable VegaChart component. --- .../components/scatterplot_matrix/scatterplot_matrix.tsx | 6 +++++- .../scatterplot_matrix/scatterplot_matrix_vega_lite_spec.ts | 2 +- .../ml/public/application/components/vega_chart/index.ts | 5 +++-- .../classification_exploration/evaluate_panel.tsx | 6 +++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx index 8f74c711a0e00..a4f68c84ba81f 100644 --- a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx +++ b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx @@ -26,7 +26,11 @@ import { useMlApiContext } from '../../contexts/kibana'; import { getProcessedFields } from '../data_grid'; import { useCurrentEuiTheme } from '../color_range_legend'; -import { LegendType, VegaChart, VegaChartLoading } from '../vega_chart'; + +// Separate imports for lazy loadable VegaChart and related code +import { VegaChart } from '../vega_chart'; +import type { LegendType } from '../vega_chart/common'; +import { VegaChartLoading } from '../vega_chart/vega_chart_loading'; import { getScatterplotMatrixVegaLiteSpec, diff --git a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix_vega_lite_spec.ts b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix_vega_lite_spec.ts index b9e37fc1376b8..f99aa7c5c3de8 100644 --- a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix_vega_lite_spec.ts +++ b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix_vega_lite_spec.ts @@ -15,7 +15,7 @@ import { euiPaletteColorBlind, euiPaletteNegative, euiPalettePositive } from '@e import { i18n } from '@kbn/i18n'; -import { LegendType, LEGEND_TYPES } from '../vega_chart'; +import { LegendType, LEGEND_TYPES } from '../vega_chart/common'; export const OUTLIER_SCORE_FIELD = 'outlier_score'; diff --git a/x-pack/plugins/ml/public/application/components/vega_chart/index.ts b/x-pack/plugins/ml/public/application/components/vega_chart/index.ts index d159af9144e63..f1d5c3ed4523b 100644 --- a/x-pack/plugins/ml/public/application/components/vega_chart/index.ts +++ b/x-pack/plugins/ml/public/application/components/vega_chart/index.ts @@ -5,6 +5,7 @@ * 2.0. */ -export { LegendType, LEGEND_TYPES } from './common'; +// Make sure to only export the component we can lazy load here. +// Code from other files in this directory should be imported directly from the file, +// otherwise we break the bundling approach using lazy loading. export { VegaChart } from './vega_chart'; -export { VegaChartLoading } from './vega_chart_loading'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx index 877cd2ec9d6d8..20866bf43a2f4 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx @@ -21,7 +21,11 @@ import { EuiTitle, } from '@elastic/eui'; import { useMlKibana } from '../../../../../contexts/kibana'; -import { VegaChart, VegaChartLoading } from '../../../../../components/vega_chart'; + +// Separate imports for lazy loadable VegaChart and related code +import { VegaChart } from '../../../../../components/vega_chart'; +import { VegaChartLoading } from '../../../../../components/vega_chart/vega_chart_loading'; + import { ErrorCallout } from '../error_callout'; import { getDependentVar, DataFrameAnalyticsConfig } from '../../../../common'; import { DataFrameTaskStateType } from '../../../analytics_management/components/analytics_list/common';