[Security Solution] Reduce initial bundle size#78992
[Security Solution] Reduce initial bundle size#78992oatkiller merged 23 commits intoelastic:masterfrom
Conversation
There was a problem hiding this comment.
I moved this to x-pack/plugins/security_solution/public/app/types.ts. This change isn't really necessary.
There was a problem hiding this comment.
Adding explicit types for readability.
There was a problem hiding this comment.
These are now loaded dynamically via x-pack/plugins/security_solution/public/lazy_plugin_dependencies.tsx
There was a problem hiding this comment.
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.
rylnd
left a comment
There was a problem hiding this comment.
@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.
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 inmasterwith the only change being that all dynamic imports had awebpackChunkNamemagic 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
resolverchunks are only used in tests.screenshots
The app still loads.

For maintainers