Skip to content

Commit dbb9982

Browse files
authored
[Lens] Reduce initial bundle size (#78142) (#78823)
1 parent 72388e6 commit dbb9982

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+192
-116
lines changed

x-pack/plugins/lens/public/app_plugin/_index.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.

x-pack/plugins/lens/public/app_plugin/app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import './app.scss';
8+
79
import _ from 'lodash';
810
import React, { useState, useEffect, useCallback } from 'react';
911
import { i18n } from '@kbn/i18n';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* This file re-exports all parts of visualizations and datasources which can be loaded lazily
9+
* (to reduce page load bundle size) when Lens is actually accessed via editor or embeddable.
10+
*
11+
* It's also possible for each visualization and datasource to resolve this locally, but this causes
12+
* a burst of bundles being loaded on Lens startup at once (and in some scenarios cascading bundle loads).
13+
* This file causes all of them to be served in a single request.
14+
*/
15+
16+
export * from './datatable_visualization/datatable_visualization';
17+
export * from './metric_visualization/metric_visualization';
18+
export * from './pie_visualization/pie_visualization';
19+
export * from './xy_visualization/xy_visualization';
20+
21+
export * from './indexpattern_datasource/indexpattern';
22+
23+
export * from './editor_frame_service/editor_frame';
24+
export * from './app_plugin/mounter';

x-pack/plugins/lens/public/datatable_visualization/_index.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export * from './expression';
8+
export * from './visualization';

x-pack/plugins/lens/public/datatable_visualization/expression.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import './expression.scss';
8+
79
import React, { useMemo } from 'react';
810
import ReactDOM from 'react-dom';
911
import { i18n } from '@kbn/i18n';

x-pack/plugins/lens/public/datatable_visualization/index.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*/
66

77
import { CoreSetup } from 'kibana/public';
8-
import { datatableVisualization } from './visualization';
98
import { ExpressionsSetup } from '../../../../../src/plugins/expressions/public';
10-
import { datatable, datatableColumns, getDatatableRenderer } from './expression';
119
import { EditorFrameSetup, FormatFactory } from '../types';
1210
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
1311
import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
@@ -29,16 +27,24 @@ export class DatatableVisualization {
2927
core: CoreSetup<DatatableVisualizationPluginStartPlugins, void>,
3028
{ expressions, formatFactory, editorFrame }: DatatableVisualizationPluginSetupPlugins
3129
) {
32-
expressions.registerFunction(() => datatableColumns);
33-
expressions.registerFunction(() => datatable);
34-
expressions.registerRenderer(() =>
35-
getDatatableRenderer({
36-
formatFactory,
37-
getType: core
38-
.getStartServices()
39-
.then(([_, { data: dataStart }]) => dataStart.search.aggs.types.get),
40-
})
41-
);
42-
editorFrame.registerVisualization(datatableVisualization);
30+
editorFrame.registerVisualization(async () => {
31+
const {
32+
datatable,
33+
datatableColumns,
34+
getDatatableRenderer,
35+
datatableVisualization,
36+
} = await import('../async_services');
37+
expressions.registerFunction(() => datatableColumns);
38+
expressions.registerFunction(() => datatable);
39+
expressions.registerRenderer(() =>
40+
getDatatableRenderer({
41+
formatFactory,
42+
getType: core
43+
.getStartServices()
44+
.then(([_, { data: dataStart }]) => dataStart.search.aggs.types.get),
45+
})
46+
);
47+
return datatableVisualization;
48+
});
4349
}
4450
}

x-pack/plugins/lens/public/drag_drop/_index.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)