Skip to content

[chore] Tweak io-ts config on shared bundle#217202

Merged
dej611 merged 4 commits intoelastic:mainfrom
dej611:fix/io-ts-deps
Apr 9, 2025
Merged

[chore] Tweak io-ts config on shared bundle#217202
dej611 merged 4 commits intoelastic:mainfrom
dej611:fix/io-ts-deps

Conversation

@dej611
Copy link
Copy Markdown
Contributor

@dej611 dej611 commented Apr 4, 2025

Summary

Save ~250kb out of thin air by tweaking the webpack configuration for the io-ts package.

@dej611 dej611 added Team:Operations Kibana-Operations Team release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Apr 7, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiAssistantManagementSelection 66 64 -2
apm 1892 1890 -2
infra 1436 1433 -3
inventory 236 234 -2
investigateApp 266 264 -2
observability 1298 1296 -2
observabilityAIAssistantApp 439 437 -2
observabilityAiAssistantManagement 386 384 -2
profiling 291 289 -2
slo 1124 1122 -2
streamsApp 447 445 -2
synthetics 1199 1197 -2
uptime 792 790 -2
ux 182 180 -2
total -29

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/ui-shared-deps-src 55 58 +3

Async chunks

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

id before after diff
aiAssistantManagementSelection 93.1KB 72.6KB -20.4KB
apm 2.6MB 2.6MB -20.4KB
infra 1.2MB 1.2MB -20.6KB
inventory 212.2KB 191.9KB -20.4KB
investigateApp 189.9KB 190.0KB +8.0B
observability 1.3MB 1.3MB -20.2KB
observabilityAIAssistantApp 265.0KB 244.6KB -20.4KB
observabilityAiAssistantManagement 107.1KB 86.7KB -20.4KB
profiling 404.1KB 383.7KB -20.4KB
slo 917.2KB 917.2KB +10.0B
streamsApp 428.2KB 407.8KB -20.4KB
synthetics 979.3KB 959.0KB -20.4KB
uptime 524.4KB 503.7KB -20.7KB
ux 170.0KB 149.6KB -20.4KB
total -245.0KB

Page load bundle

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

id before after diff
aiAssistantManagementSelection 5.3KB 5.3KB +52.0B
apm 35.0KB 35.1KB +69.0B
infra 49.5KB 49.5KB +69.0B
inventory 13.5KB 13.5KB +53.0B
investigateApp 11.6KB 11.6KB +68.0B
kbnUiSharedDeps-srcJs 3.6MB 3.6MB +928.0B
observability 94.6KB 94.6KB +68.0B
observabilityAIAssistantApp 15.7KB 15.8KB +53.0B
observabilityAiAssistantManagement 5.8KB 5.8KB +52.0B
profiling 18.2KB 18.3KB +68.0B
slo 42.4KB 42.5KB +68.0B
streamsApp 9.6KB 9.7KB +53.0B
synthetics 37.9KB 38.0KB +68.0B
uptime 53.5KB 53.5KB +20.0B
ux 7.2KB 7.2KB +53.0B
total +1.7KB
Unknown metric groups

API count

id before after diff
@kbn/ui-shared-deps-src 64 67 +3

async chunk count

id before after diff
uptime 15 14 -1

History

@dej611 dej611 marked this pull request as ready for review April 8, 2025 14:26
@dej611 dej611 requested a review from a team as a code owner April 8, 2025 14:26
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@dej611 dej611 changed the title [chore] Tweak io-ts config [chore] Tweak io-ts config on shared bundle Apr 8, 2025
@dej611 dej611 added backport:version Backport to applied version labels v9.1.0 v8.19.0 and removed backport:skip This PR does not require backporting labels Apr 9, 2025
@dej611 dej611 merged commit 99d6c85 into elastic:main Apr 9, 2025
16 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/14352337143

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 9, 2025
## Summary

Save ~250kb out of thin air by tweaking the webpack configuration for
the `io-ts` package.

(cherry picked from commit 99d6c85)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 9, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[chore] Tweak io-ts config on shared bundle
(#217202)](#217202)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-09T08:15:55Z","message":"[chore]
Tweak io-ts config on shared bundle (#217202)\n\n## Summary\n\nSave
~250kb out of thin air by tweaking the webpack configuration for\nthe
`io-ts`
package.","sha":"99d6c85e027854555ac3acf07f1490241db71152","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:version","v9.1.0","v8.19.0"],"title":"[chore]
Tweak io-ts config on shared
bundle","number":217202,"url":"https://github.com/elastic/kibana/pull/217202","mergeCommit":{"message":"[chore]
Tweak io-ts config on shared bundle (#217202)\n\n## Summary\n\nSave
~250kb out of thin air by tweaking the webpack configuration for\nthe
`io-ts`
package.","sha":"99d6c85e027854555ac3acf07f1490241db71152"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217202","number":217202,"mergeCommit":{"message":"[chore]
Tweak io-ts config on shared bundle (#217202)\n\n## Summary\n\nSave
~250kb out of thin air by tweaking the webpack configuration for\nthe
`io-ts`
package.","sha":"99d6c85e027854555ac3acf07f1490241db71152"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
dej611 added a commit that referenced this pull request Apr 17, 2025
## Summary

After #217202 and #217034 this the another attempt with `lodash` and
`lodash/fp`.

In short:
`lodash` and `lodash/fp` have a special webpack treatment as they are
imported within the shared bundle.
Now webpack is not smart enough to understand that `import camelCase
from 'lodash/camelCase';` is still pointing to `lodash` and it thinks
that `lodash/camelCase` is a different package, de-optimizing the
bundling caching system.
So I’ve tweaked the import to make it point to the shared bundle and
save few kbs here and there
davismcphee pushed a commit to davismcphee/kibana that referenced this pull request Apr 22, 2025
## Summary

After elastic#217202 and elastic#217034 this the another attempt with `lodash` and
`lodash/fp`.

In short:
`lodash` and `lodash/fp` have a special webpack treatment as they are
imported within the shared bundle.
Now webpack is not smart enough to understand that `import camelCase
from 'lodash/camelCase';` is still pointing to `lodash` and it thinks
that `lodash/camelCase` is a different package, de-optimizing the
bundling caching system.
So I’ve tweaked the import to make it point to the shared bundle and
save few kbs here and there
dej611 added a commit that referenced this pull request Apr 24, 2025
## Summary

Similar to #217034, #217202 and #217467 this time applied to
`react-use`.

This is a slightly different approach than #217034 as we're caching here
only the most common/frequently used methods from the `react-use`
library and leaving the rest to be loaded within the specific plugin
chunks.

What this PR does it fundamentally:
* adds `7.x kb` to the shared bundle
* overall the startup bundle size shrinks about `3.5 kb`
* the async bundle size shrinks of about `350 kb` (mainly due to 3
imports which were targeting `react-use/lib`).

An alternative approach would be to just fix the async import strings in
there, but I thought to it was worth it to make the long step here.
Feedback appreciated.
@dej611 dej611 self-assigned this Apr 28, 2025
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
## Summary

After elastic#217202 and elastic#217034 this the another attempt with `lodash` and
`lodash/fp`.

In short:
`lodash` and `lodash/fp` have a special webpack treatment as they are
imported within the shared bundle.
Now webpack is not smart enough to understand that `import camelCase
from 'lodash/camelCase';` is still pointing to `lodash` and it thinks
that `lodash/camelCase` is a different package, de-optimizing the
bundling caching system.
So I’ve tweaked the import to make it point to the shared bundle and
save few kbs here and there
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
)

## Summary

Similar to elastic#217034, elastic#217202 and elastic#217467 this time applied to
`react-use`.

This is a slightly different approach than elastic#217034 as we're caching here
only the most common/frequently used methods from the `react-use`
library and leaving the rest to be loaded within the specific plugin
chunks.

What this PR does it fundamentally:
* adds `7.x kb` to the shared bundle
* overall the startup bundle size shrinks about `3.5 kb`
* the async bundle size shrinks of about `350 kb` (mainly due to 3
imports which were targeting `react-use/lib`).

An alternative approach would be to just fix the async import strings in
there, but I thought to it was worth it to make the long step here.
Feedback appreciated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Operations Kibana-Operations Team v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants