Skip to content

[8.10] [Logs] Amend lazy imports in logs_shared plugin (#164102)#164180

Merged
kibanamachine merged 1 commit intoelastic:8.10from
kibanamachine:backport/8.10/pr-164102
Aug 17, 2023
Merged

[8.10] [Logs] Amend lazy imports in logs_shared plugin (#164102)#164180
kibanamachine merged 1 commit intoelastic:8.10from
kibanamachine:backport/8.10/pr-164102

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.10:

Questions ?

Please refer to the Backport tool documentation

## Summary

As part of elastic#161151 a [selection of
component imports were made
lazy](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/index.ts#L52)
and wrapped with a [`dynamic` wrapper
component](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/common/dynamic.tsx#L22).
Unfortunately some of these imports did not adhere to the rules of
React's `lazy` imports (needing a `default` export, no named imports
etc), and the `dynamic` wrapper seems to have suppressed error
information that would have been available via using `lazy` directly.

Only the anomaly and categories log entry examples (in the expanded
rows) were affected by this, as the stream and embeddable import from
locations that were backed by a `default` export (and those top level
components don't import from that particular index file lower in the
hierarchy). For imports that weren't backed by a `default` I've added
them, and where necessary moved components to new files if needed (since
it's one `default` per file).

Also open to suggestions of ways we can alter the `<dynamic />`
component and maintain the error safety 🤔

## Examples

Without these changes:

![Screenshot 2023-08-16 at 17 35
50](https://github.com/elastic/kibana/assets/471693/78aa0300-109e-40b5-b64f-6574a547cbf3)

Warning using `lazy` directly without the `dynamic` wrapper:

![Screenshot 2023-08-16 at 17 36
27](https://github.com/elastic/kibana/assets/471693/a71e3c72-cf3a-4846-9ee9-df70c1729b03)

## Testing

- Check all instances render correctly (stream, embeddable uses, and ML
page log entry examples).

(cherry picked from commit a96785c)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Aug 17, 2023
@kibanamachine kibanamachine enabled auto-merge (squash) August 17, 2023 13:50
@kibanamachine kibanamachine merged commit 8b8a028 into elastic:8.10 Aug 17, 2023
@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
logsShared 196 198 +2

Async chunks

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

id before after diff
logsShared 56.8KB 54.6KB -2.2KB

Page load bundle

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

id before after diff
logsShared 219.3KB 219.4KB +12.0B
Unknown metric groups

async chunk count

id before after diff
logsShared 8 9 +1

ESLint disabled line counts

id before after diff
logsShared 6 15 +9

Total ESLint disabled count

id before after diff
logsShared 9 18 +9

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

cc @Kerry350

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants