Skip to content

Commit

Permalink
update bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Sep 7, 2023
1 parent af66475 commit b53836d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pageLoadAssetSize:
core: 435325
crossClusterReplication: 65408
customIntegrations: 22034
dashboard: 136103
dashboard: 82025
dashboardEnhanced: 65646
data: 454087
dataViewEditor: 28082
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { DashboardAPIContext } from '../dashboard_app/dashboard_app';
import { DashboardContainer } from '../dashboard_container';
import {
InternalDashboardTopNav,
InternalDashboardTopNavProps,
} from './internal_dashboard_top_nav';
export interface DashboardTopNavProps extends InternalDashboardTopNavProps {
dashboardContainer: DashboardContainer;
}

export const DashboardTopNavWithContext = (props: DashboardTopNavProps) => (
<DashboardAPIContext.Provider value={props.dashboardContainer}>
<InternalDashboardTopNav {...props} />
</DashboardAPIContext.Provider>
);

// eslint-disable-next-line import/no-default-export
export default DashboardTopNavWithContext;
17 changes: 4 additions & 13 deletions src/plugins/dashboard/public/dashboard_top_nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,24 @@
* Side Public License, v 1.
*/
import React, { Suspense } from 'react';
import { DashboardAPIContext } from '../dashboard_app/dashboard_app';
import { DashboardContainer } from '../dashboard_container';
import { servicesReady } from '../plugin';
import { InternalDashboardTopNavProps } from './dashboard_top_nav';

export interface DashboardTopNavProps extends InternalDashboardTopNavProps {
dashboardContainer: DashboardContainer;
}
import { DashboardTopNavProps } from './dashboard_top_nav_with_context';

const LazyDashboardTopNav = React.lazy(() =>
(async () => {
const modulePromise = import('./dashboard_top_nav');
const modulePromise = import('./dashboard_top_nav_with_context');
const [module] = await Promise.all([modulePromise, servicesReady]);

return {
default: module.InternalDashboardTopNav,
default: module.DashboardTopNavWithContext,
};
})().then((module) => module)
);

export const DashboardTopNav = (props: DashboardTopNavProps) => {
const { dashboardContainer, ...rest } = props;
return (
<Suspense fallback={<div />}>
<DashboardAPIContext.Provider value={dashboardContainer}>
<LazyDashboardTopNav {...rest} />
</DashboardAPIContext.Provider>
<LazyDashboardTopNav {...props} />
</Suspense>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { SerializedStyles } from '@emotion/react';
import classNames from 'classnames';
import { TopNavMenuProps } from '@kbn/navigation-plugin/public';
import { EuiHorizontalRule, EuiIcon, EuiToolTipProps } from '@elastic/eui';
import type { ChromeProjectBreadcrumb } from '@kbn/core-chrome-browser';
import { EuiBreadcrumbProps } from '@elastic/eui/src/components/breadcrumbs/breadcrumb';
import {
getDashboardTitle,
leaveConfirmStrings,
Expand All @@ -39,7 +39,7 @@ import './_dashboard_top_nav.scss';
import { DashboardRedirect } from '../dashboard_container/types';

export interface InternalDashboardTopNavProps {
customLeadingBreadCrumbs?: ChromeProjectBreadcrumb[];
customLeadingBreadCrumbs?: EuiBreadcrumbProps[];
embedSettings?: DashboardEmbedSettings;
redirectTo: DashboardRedirect;
originatingApp?: string;
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
"@kbn/shared-ux-prompt-not-found",
"@kbn/content-management-content-editor",
"@kbn/serverless",
"@kbn/no-data-page-plugin",
"@kbn/core-chrome-browser"
"@kbn/no-data-page-plugin"
],
"exclude": ["target/**/*"]
}

0 comments on commit b53836d

Please sign in to comment.