Skip to content

Commit

Permalink
remove @kbn/presentation-containers from synthetics page load bundle (#…
Browse files Browse the repository at this point in the history
…189533)

#189128 increases
@kbn/presentation-containers size. This causes synthetics page load
bundle to exceed the bundle size limit. Synthetics page load should not
include @kbn/presentation-containers. This PR resolves the problem by
putting @kbn/presentation-containers load behind an async import

Note for reviewers, put compatibility check into its own file to avoid
importing entire @kbn/presentation-containers
into async bundle. Tree shaking is enable by putting the import in a
seperate file - see
#189206 (comment) for
more details
  • Loading branch information
nreese authored Jul 30, 2024
1 parent dc11f75 commit 6e622e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { apiIsPresentationContainer, PresentationContainer } from '@kbn/presentation-containers';
import { EmbeddableApiContext } from '@kbn/presentation-publishing';

export const compatibilityCheck = (
api: EmbeddableApiContext['embeddable']
): api is PresentationContainer => {
return apiIsPresentationContainer(api);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import { apiIsPresentationContainer } from '@kbn/presentation-containers';
import {
IncompatibleActionError,
type UiActionsActionDefinition,
Expand Down Expand Up @@ -34,10 +33,12 @@ export function createStatusOverviewPanelAction(): UiActionsActionDefinition<Emb
order: 30,
getIconType: () => 'online',
isCompatible: async ({ embeddable }) => {
return apiIsPresentationContainer(embeddable);
const { compatibilityCheck } = await import('./compatibility_check');
return compatibilityCheck(embeddable);
},
execute: async ({ embeddable }) => {
if (!apiIsPresentationContainer(embeddable)) throw new IncompatibleActionError();
const { compatibilityCheck } = await import('./compatibility_check');
if (!compatibilityCheck(embeddable)) throw new IncompatibleActionError();
try {
embeddable.addNewPanel({
panelType: SYNTHETICS_OVERVIEW_EMBEDDABLE,
Expand Down

0 comments on commit 6e622e9

Please sign in to comment.