Skip to content
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

lazy loading for infra assets #62363

Merged
merged 2 commits into from
Apr 3, 2020

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Apr 2, 2020

Summary

Part of #62263
Reduces plugin chunk size from 6.4Mb to 3.3Mb
Downloads other chunks on page mount

@mshustov mshustov requested a review from a team as a code owner April 2, 2020 18:55
@mshustov mshustov added chore release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0 Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services labels Apr 2, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@@ -75,9 +66,10 @@ export class Plugin
mount: async (params: AppMountParameters) => {
Copy link
Contributor

@spalger spalger Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we don't just stick this whole function behind an async import?

mount: async (params: AppMountParameters) => {
  (await import('./apps/mount'))(core, params);
}

Copy link
Contributor

@spalger spalger Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just think it would be a lot easier to implement correctly and maintain if everything was behind the await, not individual things being places behind the await

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I will adopt this pattern in other plugins with less logic in the mount function. I'm not comfortable touching the plugin code here due to multiple dependencies between rendering functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agree and will clean up the mess for this plugin in a follow-up (#62413).

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that the eagerly loaded bundle size of the infra plugin in the production build is only about 3 Mbytes:

grafik

The Logs and Metrics apps seem to load and function correctly.

Thank you for improving that for us. As said in a different comment, we'll refactor the entry point to reduce the eagerly loaded bundle size further.

@mshustov mshustov merged commit cb9d263 into elastic:master Apr 3, 2020
@mshustov mshustov deleted the issue-62238-infra-async-assets branch April 3, 2020 13:54
mshustov added a commit to mshustov/kibana that referenced this pull request Apr 3, 2020
mshustov added a commit to mshustov/kibana that referenced this pull request Apr 3, 2020
mshustov added a commit that referenced this pull request Apr 3, 2020
mshustov added a commit that referenced this pull request Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants