load assets lazily in es-ui plugins#62487
Conversation
cjcenizal
left a comment
There was a problem hiding this comment.
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?
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.