-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Lens] Improve Lens initial bundle size #79292
[Lens] Improve Lens initial bundle size #79292
Conversation
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
page load bundle size
To update your PR or re-run it, just comment with: |
Pinging @elastic/kibana-app (Team:KibanaApp) |
@@ -83,6 +83,8 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition { | |||
indexPatternService, | |||
} = await this.getStartServices(); | |||
|
|||
const { Embeddable } = await import('../../async_services'); |
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.
loading the actual embeddable async when required
@@ -7,7 +7,7 @@ | |||
import { Capabilities, HttpSetup } from 'kibana/public'; | |||
import { i18n } from '@kbn/i18n'; | |||
import { RecursiveReadonly } from '@kbn/utility-types'; | |||
import { toExpression, Ast } from '@kbn/interpreter/target/common'; | |||
import { Ast } from '@kbn/interpreter/target/common'; |
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.
Don't load code from interpreter within the factory (because it's part of the initial bundle)
@@ -25,10 +25,8 @@ import { Document } from '../persistence/saved_object_store'; | |||
import { mergeTables } from './merge_tables'; | |||
import { formatColumn } from './format_column'; | |||
import { EmbeddableFactory, LensEmbeddableStartServices } from './embeddable/embeddable_factory'; | |||
import { getActiveDatasourceIdFromDoc } from './editor_frame/state_management'; |
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.
Load some helpers async when needed because they pull in a tail of other modules
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, tested in firefox
This PR reduces the initial bundle size of Lens by moving a few more files behind the lazy import boundary in
async_services
.Most of the changes are due to the fact the embeddable got the static
toExpression
function of the interpreter passed in as parameter (I guess this was done to simplify unit testing). I switched to a different approach here (mocking the result ofdocumentToExpression
) which made that unnecessary.