elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.72k stars 8.14k forks source link

[Meta] Reducing Kibana bundle sizes #88678

Open Bamieh opened 3 years ago

Bamieh commented 3 years ago

I was checking opportunities for us to improve page load perofmance for kibana. This is a meta issue with some of my findings. We can create PRs or separate issues for tackling each one on the list individually. I only looked at package.json dependencies; maybe we can get rid of some devDependencies as well to reduce yarn install time in the future.

Bundle specific changes

Copied from https://github.com/elastic/kibana/issues/95853

One of our goals is to keep Kibana fast. A large part of this is to reduce the amount of Javascript that is downloaded and parsed on each page load. We have for some time provided bundle size metrics on pull requests. From the docs:

The size of the entry file produced for each bundle/plugin. This file is always loaded on every page load, so it should be as small as possible. To reduce this metric you can put any code that isn’t necessary on every page load behind an async import().

Code that is shared statically with other plugins will contribute to the page load bundle size of that plugin. This includes exports from the public/index.ts file and any file referenced by the extraPublicDirs manifest property.

Cross bundle changes

Complete

Moving packages from dependencies to devDependencies is just for keeping things tidy. Operations filter down unused dependencies before bundling. Feel free to edit this issue ❤️

elasticmachine commented 3 years ago

Pinging @elastic/kibana-core (Team:Core)

elasticmachine commented 3 years ago

Pinging @elastic/kibana-operations (Team:Operations)

mshustov commented 3 years ago

There are lots of packages duplicated in yarn.lock with different versions(see d3, vega, and others). Is it possible to automate the check that dependency update reduces the number of different versions?

spalger commented 3 years ago

We have a step in kbn bootstrap that inspects the yarn.lock, package.json, etc, and could definitely implement some dedupe validation if we could define the exact criteria we want to implement. I'm in favor of keeping a list of dependencies which we explicitly want to limit like we've done for lodash

Bamieh commented 3 years ago

I've created a PR to remove xregexp dependency from the codebase (https://github.com/elastic/kibana/pull/91369)

mshustov commented 3 years ago

@Bamieh are there any plans to remove deprecated intl-relativeformat and update intl-messageformat to the version relying on the global Intl object?

Bamieh commented 3 years ago

@restrry yes! I have an issue for upgrading those in the backlog. I'll add it to the list above too :+1:

mshustov commented 3 years ago

@Bamieh Some code still uses Bluebird we can migrate to native Promises instead

Bamieh commented 3 years ago

@restrry added to the list. Native promises caught up with both performance and features to what bluebird used to offer.

Bamieh commented 3 years ago

I've created a PR to remove bluebird dependency from the codebase (https://github.com/elastic/kibana/pull/95191)

watson commented 2 years ago

I took a stab at removing bluebird in main: #118097

watson commented 2 years ago

Bluebird removed ✅

Bamieh commented 2 years ago

@watson you're awesome :) thanks

vadimkibana commented 2 years ago

AppServices is the main user of rison-node.