-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution] Reduce initial bundle size #78992
Conversation
import { SecurityApp } from './app'; | ||
import { AppFrontendLibs } from '../common/lib/lib'; | ||
|
||
interface RenderAppProps extends AppFrontendLibs, AppMountParameters { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to x-pack/plugins/security_solution/public/app/types.ts
. This change isn't really necessary.
@@ -27,7 +17,7 @@ export const renderApp = ({ | |||
services, | |||
store, | |||
SubPluginRoutes, | |||
}: RenderAppProps) => { | |||
}: RenderAppProps): (() => void) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding explicit types for readability.
import { ConfigureEndpointPackagePolicy } from './management/pages/policy/view/ingest_manager_integration/configure_package_policy'; | ||
|
||
import { State, createStore, createInitialState } from './common/store'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are now loaded dynamically via x-pack/plugins/security_solution/public/lazy_plugin_dependencies.tsx
import('./app'), | ||
import('./common/lib/compose/kibana_compose'), | ||
]); | ||
private async downloadAssets(): Promise<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
downloadAssets
downloadSubPlugins
and buildStore
are all needed if and only if a user has interacted with on of the registered apps. They all pull their dynamic dependencies from x-pack/plugins/security_solution/public/lazy_plugin_dependencies.tsx
now.
We could refactor the code here for clarity but I tried to keep my changes as unobtrusive as possible as the 7.10 feature freeze is nearly here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oatkiller this is fantastic, thanks for looking into this. I had one question but this looks good to me. For posterity: this should close #64589.
This reverts commit 641aa763b7ae4b457256331bee819476f24d21a6.
854fb99
to
b1ce143
Compare
const appLibs: AppObservableLibs = { apolloClient, kibana: coreStart }; | ||
const libs$ = new BehaviorSubject(appLibs); | ||
|
||
const detectionsStart = detectionsSubPlugin.start(this.storage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start
is called on most of these subPlugins more than once. That seems like an issue. I'm going to look into this a bit more.
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
* Load the redux store factory and initial state factory lazily * Combine certain dynamic imports to reduce total async bundle size (this works because shared dependencies between async chunks are not being de-duped by Webpack.) * Add explicit types in some areas. Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
* Load the redux store factory and initial state factory lazily * Combine certain dynamic imports to reduce total async bundle size (this works because shared dependencies between async chunks are not being de-duped by Webpack.) * Add explicit types in some areas. Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
…otphase-to-formlib * 'master' of github.com:elastic/kibana: (59 commits) [Security Solution][Resolver] Replace copy-to-clipboard with native navigator.clipboard (elastic#80193) [Security Solution] Reduce initial bundle size (elastic#78992) [Security Solution][Resolver] Fix Resize node box-shadow bug (elastic#80223) Move observability content (elastic#79978) skip flaky suite (elastic#79389) removing kibana_datatable` in favor of `datatable` (elastic#75184) [ML] Fixes for anomaly swim lane (elastic#80299) [Lens] Smokescreen lens test unskip (elastic#80190) Improved AlertsClient tests structure by splitting a huge alerts_client.tests.ts file into a specific files defined by its responsibility. (elastic#80088) [APM] React key warning when opening popover with external resources (elastic#80328) [Step 1] use Observables on server search API (elastic#79874) Apply back pressure in Task Manager whenever Elasticsearch responds with a 429 (elastic#75666) [Lens] Leverage original http request error (elastic#79831) [Security Solution][Case] Improve ServiceConnectorCaseParams type (elastic#80109) [SECURITY_SOLUTION] Fix query on alert histogram (elastic#80219) [DOCS] Update ingest node pipelines doc (elastic#79187) [Ingest Manager] Split up OpenAPI spec file (elastic#80107) [SECURITY_SOLUTION][ENDPOINT] Fix label on Trusted App create name field (elastic#80001) [Ingest Manager] Fix agent policy bump revision to create only one POLICY_CHANGE action (elastic#80081) Grid layout fixes (elastic#80305) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared/data_tier_allocation_field.tsx # x-pack/plugins/index_lifecycle_management/public/shared_imports.ts
* Load the redux store factory and initial state factory lazily * Combine certain dynamic imports to reduce total async bundle size (this works because shared dependencies between async chunks are not being de-duped by Webpack.) * Add explicit types in some areas. Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Summary
Here is a screenshot of the webpack analyse UI with the
stats.json
(dist version) of our plugin as it is inmaster
with the only change being that all dynamic imports had awebpackChunkName
magic comment added:Here is a screenshot of the same UI with the
stats.json
(dist version) or our plugin as it is in this PR.Note that today the
resolver
chunks are only used in tests.screenshots
The app still loads.
For maintainers