-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[data.ui] Lazy load UI components in data plugin. #78889
Conversation
69fed12
to
d003dfe
Compare
import { phraseFilter } from '../../../../stubs'; | ||
|
||
afterEach(cleanup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cleanups
should no longer be needed as explained in #78742
// @internal | ||
export { ShardFailureOpenModalButton, ShardFailureRequest } from './shard_failure_modal'; | ||
|
||
// @internal | ||
export { SavedQueryManagementComponent } from './saved_query_management'; | ||
|
||
// @internal | ||
export { SaveQueryForm, SavedQueryMeta } from './saved_query_form'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data/public/index.ts
imports from this file, so I have removed any items which are imported internally by other lazy-loaded components. This way the only items available in ui/index
are types, or lazy-loaded components.
await waitFor(() => getByText(kqlQuery.query)); | ||
await waitFor(() => getByText('KQL')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitFor
already fails if the items you are querying for don't exist, so we no longer need the assertions that were here previously.
const SEARCH_BAR_ROOT = '.globalQueryBar'; | ||
const FILTER_BAR = '.filterBar'; | ||
const FILTER_BAR = '.globalFilterBar'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I have no clue how this test worked previously with the .filterBar
class... I couldn't find it anywhere in the DOM. So I replaced it with .globalFilterBar
which definitely exists 🙂
// The data plugin's `SearchBar` is lazy loaded, so we need to ensure it is | ||
// available before we mount our component with Enzyme. | ||
const getWrapper = async (Component: ReturnType<typeof Proxy>) => { | ||
const { getByTestId } = render(Component); | ||
await waitFor(() => getByTestId('queryInput')); // check for presence of query input | ||
return mount(Component); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.Suspense
doesn't play nice with Enzyme, but I wanted to avoid re-writing each test with @testing-library/react
since I'm not familiar with this area of code. So I made this wrapper which ensures the SearchBar
that's loaded with React.lazy
is available before Enzyme mount
is called.
You may want to consider a rewrite with @testing-library/react
that doesn't rely on <SearchBar />
internals, as it should speed these tests up a bit. (Or perhaps a functional test if you really want to test the end-to-end experience).
d003dfe
to
3ee8d4d
Compare
Pinging @elastic/kibana-app-arch (Team:AppArch) |
After several attempts, I've been unable to reproduce these failures locally, however they are failing consistently so I'll keep investigating.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good and work well locally. Nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code only review - but Kibana App changes LGTM
I haven't had any luck getting to the bottom of this failed maps functional test, so I've pinged @elastic/kibana-gis for input:
Since this test doesn't appear to have been failing on other branches lately, I'm trying to figure out what I changed that might have affected this test. The two components which are now lazy loaded that I could find usage of in the maps app are One hypothesis I had was that perhaps the I did a few things to try to reproduce the failure locally:
In all cases I was still unable to reproduce the failure 🙁 The screenshot from the test artifacts doesn't show any obvious rendering problems either: At this point I've adjusted the height of the But if this next run still fails, I might need some more expertise from @elastic/kibana-gis. |
3ee8d4d
to
9f98cd8
Compare
9f98cd8
to
acda6d9
Compare
// Allow a range of hits to account for variances in browser window size. | ||
expect(parseInt(hits)).to.be.within(30, 40); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @nreese, and he agreed that in this case it would be fine to make this assertion a range of values to account for small variances in screen size.
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maps changes LGTM
code review
…into feature/task_manager_429 * 'feature/task_manager_429' of github.com:elastic/kibana: (158 commits) Add license check to direct package upload handler. (#79653) [Ingest Manager] Rename API /api/ingest_manager => /api/fleet (#79193) [Security Solution][Resolver] Simplify CopyableField styling and add comments (#79594) Fine-tunes ML related text on Metrics UI (#79425) [ML] DF Analytics creation wizard: ensure job creation possible when model memory lower than estimate (#79229) Add new "Add Data" tutorials (#77237) Update APM telemetry docs (#79583) Revert "Add support for runtime field types to mappings editor. (#77420)" (#79611) Kibana request headers (#79218) ensure missing indexPattern error is bubbled up to error callout (#79378) Missing space fix (#79585) remove duplicate tab states (#79501) [data.ui] Lazy load UI components in data plugin. (#78889) Add generic type params to search dependency. (#79608) [Ingest Manager] Internal action for policy reassign (#78493) [ILM] Add index_codec to forcemerge action in hot and warm phases (#78175) [Ingest Manager] Update open API spec and add condition to agent upgrade endpoint (#79579) [ML] Hide Data Grid column options when histogram charts are enabled. (#79459) [Telemetry] Synchronous `setup` and `start` methods (#79457) [Observability] Persist time range across apps (#79258) ...
In an effort to reduce the initial bundle size of the
data
plugin, this updates items exported fromdata/public/ui
to be lazy-loaded.There's more we could investigate in the data plugin longer term, but this is the quickest/easiest target for bundle size reduction that doesn't involve breaking any service contracts or making lifecycle methods async.
Here are the before and after stats from webpack-bundle-analyzer:
Before:
data/public/ui
~307kData Plugin
Closeup of
data/public/ui
After:
data/public/ui
~37kData Plugin
Closeup of
data/public/ui