Skip to content

Commit

Permalink
[Kibana Overview] Shift SCSS import and lazy-load main component (#20…
Browse files Browse the repository at this point in the history
…4661)

## Summary

Part of elastic/kibana-team#1082

The purpose of this PR is to reduce the page load bundle size of the
`kibanaOverview` plugin.

Converts the main component of the `kibanaOverview` plugin to be lazy
loaded, and shifts the import of the main SCSS file to be imported from
the lazily-loaded component. This PR does not include any changes that
would be noticeable by end-users. It changes the internals to use a
different technology for styling components.

## References
1. https://emotion.sh/docs/globals
2. https://emotion.sh/docs/best-practices
3.
elastic/eui#6828 (comment)
  • Loading branch information
tsullivan authored Dec 19, 2024
1 parent 576f3c5 commit 1861bbc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/plugins/kibana_overview/public/components/_index.scss

This file was deleted.

10 changes: 9 additions & 1 deletion src/plugins/kibana_overview/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { I18nProvider } from '@kbn/i18n-react';
import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';
import type { FetchResult } from '@kbn/newsfeed-plugin/public';
import { Route, Routes } from '@kbn/shared-ux-router';
import { withSuspense } from '@kbn/shared-ux-utility';
import React, { useEffect, useState } from 'react';
import { HashRouter as Router } from 'react-router-dom';
import useObservable from 'react-use/lib/useObservable';
import type { Observable } from 'rxjs';
import { Overview } from './overview';

interface KibanaOverviewAppDeps {
basename: string;
Expand Down Expand Up @@ -48,6 +48,14 @@ export const KibanaOverviewApp = ({
}
}, [newsfeed$]);

const Overview = withSuspense(
React.lazy(() =>
import('./overview').then(({ Overview: OverviewComponent }) => {
return { default: OverviewComponent };
})
)
);

return (
<Router basename={basename}>
<I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import './overview.scss';

import { snakeCase } from 'lodash';
import React, { FC, useState, useEffect } from 'react';
import useObservable from 'react-use/lib/useObservable';
Expand Down
1 change: 0 additions & 1 deletion src/plugins/kibana_overview/public/index.scss

This file was deleted.

2 changes: 0 additions & 2 deletions src/plugins/kibana_overview/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import './index.scss';

import { KibanaOverviewPlugin } from './plugin';

// This exports static code and TypeScript types,
Expand Down

0 comments on commit 1861bbc

Please sign in to comment.