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

lens should register expression functions in setup contract #110639

Merged
merged 12 commits into from
Sep 7, 2021

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Aug 31, 2021

Closes: #106510

Summary

lens expression functions are currently registered too late. they should be registered in setup life cycle to enable #106509

as functions are registered too late this will prevent us to run migrations on them, do reference extraction/injection or in the future use alerting or reporting services.

@@ -21,7 +21,7 @@ import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
import { Start as InspectorStart } from '../../../../../src/plugins/inspector/public';
import { Document } from '../persistence/saved_object_store';
import { LensAttributeService } from '../lens_attribute_service';
import { DOC_TYPE } from '../../common';
import { DOC_TYPE } from '../../common/constants';
Copy link
Contributor

Choose a reason for hiding this comment

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

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main problem with export * is, It cause excessive exports in required bundle see #110891. On the other hand if we are talking about build package it's important to don't load extra modules. Yes, I agree that it probably doesn't look professional, but it allow us optimize bundle size a little bit.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with having specific export directives, but in this case I'm unsure about the real gain here.

Do we have any measurable difference between import { DOC_TYPE } from '../common' and import {DOC_TYPE} from '../common/constants'? The item is exported via common/index which is pretty much imported fully imported in the setup phase of Lens.
Isn't treeshaking already taking care of all these esm exporting implementation details?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe if we avoid of using export * it starts to work correctly, but I found extra code in final bundle from which we used only constants. Replacing to '../common/constants' solved that issue

Copy link
Contributor

Choose a reason for hiding this comment

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

During the sync today Alexey demonstrated that changing this import gives us 4 KB of a smaller bundle. We agreed the change is worth it :)

# Conflicts:
#	x-pack/plugins/lens/public/lens_attribute_service.ts
#	x-pack/plugins/lens/public/plugin.ts
@alexwizp
Copy link
Contributor Author

alexwizp commented Sep 6, 2021

@elasticmachine merge upstream

@alexwizp alexwizp marked this pull request as ready for review September 6, 2021 08:39
@alexwizp alexwizp requested a review from a team as a code owner September 6, 2021 08:39
@alexwizp alexwizp self-assigned this Sep 6, 2021
@alexwizp alexwizp added Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.16.0 v8.0.0 labels Sep 6, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors (Team:VisEditors)

@alexwizp alexwizp added the release_note:skip Skip the PR/issue when compiling release notes label Sep 6, 2021
@mbondyra mbondyra requested a review from a team September 6, 2021 10:21
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
Copy link
Contributor

@mbondyra mbondyra left a comment

Choose a reason for hiding this comment

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

Great work, thank you for taking care of this one 🙇🏼‍♀️ I went through the code and didn't find anything suspicious, but it'd be good if @ppisljar and @dej611 take a look too. Tested on Chrome.

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Code review LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 829 834 +5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.6MB 1.6MB -53.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 30.7KB 58.6KB +27.9KB
Unknown metric groups

async chunk count

id before after diff
lens 3 9 +6

History

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

cc @alexwizp

heatmapGridConfig,
axisExtentConfig,
labelsOrientationConfig,
getDatatable(formatFactory),
Copy link
Member

Choose a reason for hiding this comment

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

all functions should be registered on the server side as well (not necessary part of this PR)

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM

@alexwizp alexwizp merged commit e2c6a03 into elastic:master Sep 7, 2021
alexwizp added a commit to alexwizp/kibana that referenced this pull request Sep 7, 2021
…110639)

* lens should register expression functions in setup contract

Closes: elastic#106510

* fix CI

* build optimization

* build optimizations - step 3

* fix CI

* try to optimize bundle

* Update x-pack/plugins/lens/common/expressions/time_scale/types.ts

Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>

* Update types.ts

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
alexwizp added a commit that referenced this pull request Sep 7, 2021
…#111324)

* lens should register expression functions in setup contract

Closes: #106510

* fix CI

* build optimization

* build optimizations - step 3

* fix CI

* try to optimize bundle

* Update x-pack/plugins/lens/common/expressions/time_scale/types.ts

Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>

* Update types.ts

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marta Bondyra <marta.bondyra@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lens should register expression functions in setup contract
6 participants