Skip to content

Commit

Permalink
[Maps] Make bundle smaller (elastic#95881)
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/kbn-optimizer/limits.yml
#	x-pack/plugins/uptime/public/components/monitor/status_details/location_map/embeddables/embedded_map.tsx
#	x-pack/plugins/uptime/public/components/monitor/status_details/location_map/embeddables/map_tool_tip.tsx
  • Loading branch information
thomasneirynck committed Apr 1, 2021
1 parent 102d34a commit c1b7874
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 57 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pageLoadAssetSize:
lists: 202261
logstash: 53548
management: 46112
maps: 183754
maps: 80000
mapsLegacy: 87859
mapsLegacyLicensing: 20214
ml: 82187
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { useLayerList } from './useLayerList';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { RenderTooltipContentParams } from '../../../../../../maps/public';
import type { RenderTooltipContentParams } from '../../../../../../maps/public';
import { MapToolTip } from './MapToolTip';
import { useMapFilters } from './useMapFilters';
import { EmbeddableStart } from '../../../../../../../../src/plugins/embeddable/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
TRANSACTION_DURATION_COUNTRY,
TRANSACTION_DURATION_REGION,
} from './useLayerList';
import { RenderTooltipContentParams } from '../../../../../../maps/public';
import type { RenderTooltipContentParams } from '../../../../../../maps/public';
import { I18LABELS } from '../translations';

type MapToolTipProps = Partial<RenderTooltipContentParams>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import _ from 'lodash';
import { Filter } from '../../../../../../src/plugins/data/public';
import { TooltipFeature } from '../../../../../plugins/maps/common/descriptor_types';
import type { TooltipFeature } from '../../../../../plugins/maps/common/descriptor_types';

export interface ITooltipProperty {
getPropertyKey(): string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
EmbeddableFactoryDefinition,
IContainer,
} from '../../../../../src/plugins/embeddable/public';
import '../index.scss';
import { MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
import { getMapEmbeddableDisplayName } from '../../common/i18n_getters';
import { MapByReferenceInput, MapEmbeddableInput, MapByValueInput } from './types';
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/maps/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const plugin: PluginInitializer<MapsPluginSetup, MapsPluginStart> = (

export { MAP_SAVED_OBJECT_TYPE } from '../common/constants';

export { RenderTooltipContentParams } from './classes/tooltips/tooltip_property';
export type { RenderTooltipContentParams } from './classes/tooltips/tooltip_property';

export { MapsStartApi } from './api';

export type { MapEmbeddable, MapEmbeddableInput } from './embeddable';
29 changes: 21 additions & 8 deletions x-pack/plugins/maps/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
* 2.0.
*/

import _ from 'lodash';
import { CoreStart } from 'kibana/public';
import type { CoreStart } from 'kibana/public';
import type { MapsEmsConfig } from '../../../../src/plugins/maps_ems/public';
import { MapsConfigType } from '../config';
import { MapsPluginStartDependencies } from './plugin';
import { EMSSettings } from '../common/ems_settings';
import { PaletteRegistry } from '../../../../src/plugins/charts/public';
import type { MapsConfigType } from '../config';
import type { MapsPluginStartDependencies } from './plugin';
import type { EMSSettings } from '../common/ems_settings';
import type { PaletteRegistry } from '../../../../src/plugins/charts/public';

let kibanaVersion: string;
export const setKibanaVersion = (version: string) => (kibanaVersion = version);
Expand Down Expand Up @@ -75,8 +74,22 @@ export const getEMSSettings = () => {

export const getEmsTileLayerId = () => getKibanaCommonConfig().emsTileLayerId;

export const getRegionmapLayers = () => _.get(getKibanaCommonConfig(), 'regionmap.layers', []);
export const getTilemap = () => _.get(getKibanaCommonConfig(), 'tilemap', []);
export const getRegionmapLayers = () => {
const config = getKibanaCommonConfig();
if (config.regionmap && config.regionmap.layers) {
return config.regionmap.layers;
} else {
return [];
}
};
export const getTilemap = () => {
const config = getKibanaCommonConfig();
if (config.tilemap) {
return config.tilemap;
} else {
return {};
}
};

export const getShareService = () => pluginsStart.share;

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/public/lazy_load_bundle/lazy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import '../../index.scss';
export * from '../../embeddable/map_embeddable';
export * from '../../kibana_services';
export { renderApp } from '../../render_app';
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/maps/public/maps_vis_type_alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

import { i18n } from '@kbn/i18n';
import {
import type {
VisualizationsSetup,
VisualizationStage,
} from '../../../../src/plugins/visualizations/public';
import { SavedObject } from '../../../../src/core/types/saved_objects';
import { MapSavedObject } from '../common/map_saved_object_type';
import type { SavedObject } from '../../../../src/core/types/saved_objects';
import type { MapSavedObject } from '../common/map_saved_object_type';
import {
APP_ID,
APP_ICON,
Expand Down
37 changes: 18 additions & 19 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* 2.0.
*/

import { Setup as InspectorSetupContract } from 'src/plugins/inspector/public';
import { UiActionsStart } from 'src/plugins/ui_actions/public';
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
import { Start as InspectorStartContract } from 'src/plugins/inspector/public';
import { DashboardStart } from 'src/plugins/dashboard/public';
import {
import type { Setup as InspectorSetupContract } from 'src/plugins/inspector/public';
import type { UiActionsStart } from 'src/plugins/ui_actions/public';
import type { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
import type { Start as InspectorStartContract } from 'src/plugins/inspector/public';
import type { DashboardStart } from 'src/plugins/dashboard/public';
import type {
AppMountParameters,
CoreSetup,
CoreStart,
Plugin,
PluginInitializerContext,
DEFAULT_APP_CATEGORIES,
} from '../../../../src/core/public';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/public';
// @ts-ignore
import { MapView } from './inspector/views/map_view';
import {
Expand All @@ -29,8 +29,8 @@ import {
} from './kibana_services';
import { featureCatalogueEntry } from './feature_catalogue_entry';
import { getMapsVisTypeAlias } from './maps_vis_type_alias';
import { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
import {
import type { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
import type {
VisualizationsSetup,
VisualizationsStart,
} from '../../../../src/plugins/visualizations/public';
Expand All @@ -43,28 +43,27 @@ import {
} from './url_generator';
import { visualizeGeoFieldAction } from './trigger_actions/visualize_geo_field_action';
import { MapEmbeddableFactory } from './embeddable/map_embeddable_factory';
import { EmbeddableSetup } from '../../../../src/plugins/embeddable/public';
import type { EmbeddableSetup, EmbeddableStart } from '../../../../src/plugins/embeddable/public';
import { MapsXPackConfig, MapsConfigType } from '../config';
import { getAppTitle } from '../common/i18n_getters';
import { lazyLoadMapModules } from './lazy_load_bundle';
import { MapsStartApi } from './api';
import { createLayerDescriptors, registerLayerWizard, registerSource } from './api';
import { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public';
import { EmbeddableStart } from '../../../../src/plugins/embeddable/public';
import type { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public';
import type { MapsEmsPluginSetup } from '../../../../src/plugins/maps_ems/public';
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public';
import { FileUploadPluginStart } from '../../file_upload/public';
import { SavedObjectsStart } from '../../../../src/plugins/saved_objects/public';
import { PresentationUtilPluginStart } from '../../../../src/plugins/presentation_util/public';
import type { DataPublicPluginStart } from '../../../../src/plugins/data/public';
import type { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public';
import type { FileUploadPluginStart } from '../../file_upload/public';
import type { SavedObjectsStart } from '../../../../src/plugins/saved_objects/public';
import type { PresentationUtilPluginStart } from '../../../../src/plugins/presentation_util/public';
import {
getIsEnterprisePlus,
registerLicensedFeatures,
setLicensingPluginStart,
} from './licensed_features';
import { EMSSettings } from '../common/ems_settings';
import { SavedObjectTaggingPluginStart } from '../../saved_objects_tagging/public';
import { ChartsPluginStart } from '../../../../src/plugins/charts/public';
import type { SavedObjectTaggingPluginStart } from '../../saved_objects_tagging/public';
import type { ChartsPluginStart } from '../../../../src/plugins/charts/public';

export interface MapsPluginSetupDependencies {
inspector: InspectorSetupContract;
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/maps/public/url_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
*/

import rison from 'rison-node';
import {
import type {
TimeRange,
Filter,
Query,
esFilters,
QueryState,
RefreshInterval,
} from '../../../../src/plugins/data/public';
import { esFilters } from '../../../../src/plugins/data/public';
import { setStateToKbnUrl } from '../../../../src/plugins/kibana_utils/public';
import { UrlGeneratorsDefinition } from '../../../../src/plugins/share/public';
import { LayerDescriptor } from '../common/descriptor_types';
import type { UrlGeneratorsDefinition } from '../../../../src/plugins/share/public';
import type { LayerDescriptor } from '../common/descriptor_types';
import { INITIAL_LAYERS_KEY } from '../common/constants';
import { lazyLoadMapModules } from './lazy_load_bundle';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ import minimatch from 'minimatch';
import { IndexPatternMapping } from './types';
import { getLayerList } from './map_config';
import { MAP_SAVED_OBJECT_TYPE } from '../../../../../maps/public';
import {
import type {
RenderTooltipContentParams,
MapEmbeddable,
MapEmbeddableInput,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../plugins/maps/public/embeddable';
import {
RenderTooltipContentParams,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../plugins/maps/public/classes/tooltips/tooltip_property';
} from '../../../../../../plugins/maps/public';
import * as i18n from './translations';
import { Query, Filter } from '../../../../../../../src/plugins/data/public';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { RenderTooltipContentParams } from '../../../../../maps/public/classes/tooltips/tooltip_property';
import type { RenderTooltipContentParams } from '../../../../../maps/public';

export interface IndexPatternMapping {
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import {
ViewMode,
ErrorEmbeddable,
} from '../../../../../../../../../src/plugins/embeddable/public';
import {
RenderTooltipContentParams,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../maps/public/classes/tooltips/tooltip_property';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import type { RenderTooltipContentParams } from '../../../../../../../maps/public/classes/tooltips/tooltip_property';

export interface EmbeddedMapProps {
upPoints: LocationPoint[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ import { AppState } from '../../../../../state';
import { monitorLocationsSelector } from '../../../../../state/selectors';
import { useMonitorId } from '../../../../../hooks';
import { MonitorLocation } from '../../../../../../common/runtime_types/monitor';
import type { RenderTooltipContentParams } from '../../../../../../../maps/public';
import { formatAvailabilityValue } from '../../availability_reporting/availability_reporting';
import { LastCheckLabel } from '../../translations';
import {
RenderTooltipContentParams,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../maps/public/classes/tooltips/tooltip_property';

type MapToolTipProps = Partial<RenderTooltipContentParams>;

Expand Down

0 comments on commit c1b7874

Please sign in to comment.