-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
load assets lazily in es-ui plugins #62487
Conversation
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.
LGTM
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.
Looks good, but can you help me understand the changes to Index Management and Snapshot Restore? Both of those apps were already lazy-loading before this change. So what do these changes accomplish?
x-pack/plugins/index_management/public/application/mount_management_section.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/upgrade_assistant/public/application/mount_management_section.ts
Outdated
Show resolved
Hide resolved
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.
App arch change LGTM
Index management uses singleton services that initialized on the first import. It means that:
present in the plugin bundle, even though they required when the app/management section is rendered. |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* load assets lazily * addres cj comments
* load assets lazily * addres cj comments
Thanks for doing this @restrry ! // This is for example the logic for index_management
const { http, notifications } = coreSetup;
const { usageCollection, management } = plugins;
httpService.setup(http);
notificationService.setup(notifications);
this.uiMetricService.setup(usageCollection);
// And here we register the app with the `mount` handler
management.sections.getSection('elasticsearch')!.registerApp({ ... Note: the gain on "snapshot_restore" is quite insignificant 😊 |
To move everything that possible behind |
Are you saying that the above const { http, notifications } = coreSetup; is it not available in the closure? setup(coreSetup: CoreSetup) {
const { http, notifications } = coreSetup;
management.sections.getSection('elasticsearch')!.registerApp({
id: PLUGIN.id,
title: 'myPlugin',
order: 1,
mount: async params => {
// Initiate a service with core HTTP
// Is this possible?
const apiService = new MyApiService(http);
const { mountManagementSection } = await import('./mount_app');
const services = {
apiService,
};
return mountManagementSection(services);
},
}); |
@sebelga Even if it works atm, you shouldn't rely on it in the future. |
Ok, thanks for clarifying @restrry ! |
Summary
Part of #62263
Implements lazy loading for management sections + share url.