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

Use export type instead of export to reduce bundle size #101796

Merged

Conversation

stacey-gammon
Copy link
Contributor

It appears that using export { AType } from '..' increases the bundle size, even though they are only types. Lets see what happens if we convert a bunch of those to export type { AType } from '...' in the data plugin, see if bundle size is reduced by a lot.

@stacey-gammon stacey-gammon force-pushed the 2021-06-09-data-export-type branch from 88b02ab to 564e551 Compare June 9, 2021 20:06
@stacey-gammon stacey-gammon marked this pull request as ready for review June 9, 2021 23:17
@stacey-gammon stacey-gammon requested a review from a team June 9, 2021 23:17
@stacey-gammon stacey-gammon requested a review from a team as a code owner June 9, 2021 23:17
@stacey-gammon stacey-gammon requested review from ppisljar and timroes June 9, 2021 23:17
@stacey-gammon stacey-gammon added release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v8.0.0 Team:AppServices labels Jun 9, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@ppisljar
Copy link
Member

ppisljar commented Jun 10, 2021

10kb ? less then 1% change, do you think its worth it ?

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Kibana app changes LGTM

@stacey-gammon
Copy link
Contributor Author

@ppisljar ,

10kb ? less then 1% change, do you think its worth it ?

Yea, it's a small gain, but if we do it everywhere, it could add up. @tylersmalley or @spalger - what do you think? Is using export type a useful recommendation to decrease bundle size, or something we shouldn't bother with because the gains are small?

@spalger
Copy link
Contributor

spalger commented Jun 10, 2021

I really don't think that thinking of a 10kb size change as "less than 1%" is helpful, it's a 10kb change and that's important. Reducing our bundles by 2-3mb is made up of lots of little 10kb changes. I think that one of the reasons this is only 10kb is because it's the first place we're doing this, and I think that if we make it a habit across the team and use export type in as many places as possible then we are likely to see dozens of these types of reductions which should add up. I think it's also important to not just use export type in the public/index.ts type files, but throughout the plugin, which I think is another reason we should try to make it a habit to always use export type if it's a valid option.

@stacey-gammon
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
data 572 571 -1

Page load bundle

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

id before after diff
data 840.3KB 830.9KB -9.4KB

History

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

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

@stacey-gammon stacey-gammon merged commit a7b0391 into elastic:master Jun 16, 2021
@stacey-gammon stacey-gammon added the auto-backport Deprecated - use backport:version if exact versions are needed label Jun 16, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 16, 2021
* Use export type instead of export to reduce bundle size

* Update legacy docs

* update docs again

Co-authored-by: Kibana Machine <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 16, 2021
…02344)

* Use export type instead of export to reduce bundle size

* Update legacy docs

* update docs again

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Stacey Gammon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants