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

[visualizations] lazy load actions #207147

Merged
merged 18 commits into from
Jan 23, 2025
Merged

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Jan 18, 2025

Clean up visualizations page load size by

  • lazy loading actions
  • avoid exporting from index files to avoid exporting unused code
  • move urlFor and getFullPath into url_utils to avoid including utils/saved_visualize_utils in page load bundle

@nreese
Copy link
Contributor Author

nreese commented Jan 18, 2025

/ci

@nreese
Copy link
Contributor Author

nreese commented Jan 18, 2025

/ci

@nreese
Copy link
Contributor Author

nreese commented Jan 18, 2025

/ci

@nreese
Copy link
Contributor Author

nreese commented Jan 18, 2025

/ci

@nreese
Copy link
Contributor Author

nreese commented Jan 19, 2025

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

There are no new commits on the base branch.

@nreese
Copy link
Contributor Author

nreese commented Jan 19, 2025

/ci

1 similar comment
@nreese
Copy link
Contributor Author

nreese commented Jan 19, 2025

/ci

@nreese
Copy link
Contributor Author

nreese commented Jan 19, 2025

/ci

@nreese nreese marked this pull request as ready for review January 19, 2025 17:46
@nreese nreese requested review from a team as code owners January 19, 2025 17:46
@nreese nreese added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas release_note:skip Skip the PR/issue when compiling release notes v9.0.0 labels Jan 19, 2025
@nreese nreese added project:embeddableRebuild backport:version Backport to applied version labels v8.18.0 labels Jan 19, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

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

packages/kbn-optimizer/limits.yml LGTM

@nreese
Copy link
Contributor Author

nreese commented Jan 21, 2025

@elasticmachine merge upstream

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

All good for me code wise, yested also locally, the chunk is async loaded

Comment on lines 21 to 29
uiActions.addTriggerActionAsync(CONTEXT_MENU_TRIGGER, ACTION_EDIT_IN_LENS, async () => {
const { EditInLensAction } = await import('./actions_module');
return new EditInLensAction(data.query.timefilter.timefilter);
});

uiActions.addTriggerActionAsync(ADD_PANEL_TRIGGER, ADD_AGG_VIS_ACTION_ID, async () => {
const { AddAggVisualizationPanelAction } = await import('./actions_module');
return new AddAggVisualizationPanelAction(types);
});
Copy link
Member

Choose a reason for hiding this comment

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

Instead of importing the actions_modules isn't better to directly import the Action directly from its file?
Since we are async loading these to reduce a bit the initial loading we can probably also gain a bit during the action loading if we async load the Actions independently, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that makes sense since the actions are for different triggers. Resolved with 4bcd8f0

@@ -18,7 +18,7 @@ export type HasVisualizeConfig = HasType<'visualization'> & {
export const apiHasVisualizeConfig = (api: unknown): api is HasVisualizeConfig => {
return Boolean(
api &&
apiIsOfType(api, 'visualization') &&
(api as HasType)?.type === 'visualization' &&
Copy link
Member

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.

avoid using apiIsOfType to avoid importing presentation-publishing package into page load. Since apiIsOfType is so simple, no reason to use the utility method and import such a huge bundle just for it.

@nreese
Copy link
Contributor Author

nreese commented Jan 23, 2025

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #2 / useGetCategories displays an error toast when an error occurs

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visualizations 537 538 +1

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
visualizations 838 836 -2

Async chunks

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

id before after diff
visualizations 354.2KB 379.3KB +25.2KB

Page load bundle

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

id before after diff
visualizations 62.5KB 39.2KB -23.3KB
Unknown metric groups

API count

id before after diff
visualizations 869 867 -2

async chunk count

id before after diff
visualizations 16 20 +4

References to deprecated APIs

id before after diff
visualizations 57 55 -2

History

@nreese nreese merged commit d7f801a into elastic:main Jan 23, 2025
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 23, 2025
Clean up visualizations page load size by
* lazy loading actions
* avoid exporting from index files to avoid exporting unused code
* move `urlFor` and `getFullPath` into `url_utils` to avoid including
`utils/saved_visualize_utils` in page load bundle

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit d7f801a)
@kibanamachine
Copy link
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 Jan 23, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[visualizations] lazy load actions
(#207147)](#207147)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-23T18:33:23Z","message":"[visualizations]
lazy load actions (#207147)\n\nClean up visualizations page load size
by\r\n* lazy loading actions\r\n* avoid exporting from index files to
avoid exporting unused code\r\n* move `urlFor` and `getFullPath` into
`url_utils` to avoid including\r\n`utils/saved_visualize_utils` in page
load bundle\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"d7f801ab3e9c22cc77c0fc3da9492008a5a5252a","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","v9.0.0","project:embeddableRebuild","backport:version","v8.18.0"],"title":"[visualizations]
lazy load
actions","number":207147,"url":"https://github.com/elastic/kibana/pull/207147","mergeCommit":{"message":"[visualizations]
lazy load actions (#207147)\n\nClean up visualizations page load size
by\r\n* lazy loading actions\r\n* avoid exporting from index files to
avoid exporting unused code\r\n* move `urlFor` and `getFullPath` into
`url_utils` to avoid including\r\n`utils/saved_visualize_utils` in page
load bundle\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"d7f801ab3e9c22cc77c0fc3da9492008a5a5252a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207147","number":207147,"mergeCommit":{"message":"[visualizations]
lazy load actions (#207147)\n\nClean up visualizations page load size
by\r\n* lazy loading actions\r\n* avoid exporting from index files to
avoid exporting unused code\r\n* move `urlFor` and `getFullPath` into
`url_utils` to avoid including\r\n`utils/saved_visualize_utils` in page
load bundle\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"d7f801ab3e9c22cc77c0fc3da9492008a5a5252a"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <[email protected]>
qn895 pushed a commit to qn895/kibana that referenced this pull request Jan 23, 2025
Clean up visualizations page load size by
* lazy loading actions
* avoid exporting from index files to avoid exporting unused code
* move `urlFor` and `getFullPath` into `url_utils` to avoid including
`utils/saved_visualize_utils` in page load bundle

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Jan 27, 2025
Clean up visualizations page load size by
* lazy loading actions
* avoid exporting from index files to avoid exporting unused code
* move `urlFor` and `getFullPath` into `url_utils` to avoid including
`utils/saved_visualize_utils` in page load bundle

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
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 project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants