-
Notifications
You must be signed in to change notification settings - Fork 3.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
refactor(ui): code-split out large xterm
dep
#12158
Merged
agilgur5
merged 7 commits into
argoproj:main
from
agilgur5:refactor-ui-code-split-xterm
May 24, 2024
Merged
refactor(ui): code-split out large xterm
dep
#12158
agilgur5
merged 7 commits into
argoproj:main
from
agilgur5:refactor-ui-code-split-xterm
May 24, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
agilgur5
force-pushed
the
refactor-ui-code-split-xterm
branch
from
January 20, 2024 07:37
35c2dd8
to
4c63766
Compare
This was referenced Feb 1, 2024
agilgur5
force-pushed
the
refactor-ui-code-split-xterm
branch
2 times, most recently
from
May 13, 2024 20:24
14b9dfb
to
93d9361
Compare
19 tasks
- after the past few code-splits, `xterm` was left as one of the largest deps in the main bundle - `xterm` is only used by `argo-ui` in its `LogsViewer` component, which is only used by Workflows' `FullHeightLogsViewer` component - so lazy load `LogsViewer` within `FullHeightLogsViewer` in order to code-split it - add a [`webpackPrefetch`](https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules) magic comment as logs are _very_ commonly used, at least in my experience - **NOTE**: this is currently **not working** as a code-split as `argo-ui` does not seem to be tree-shakeable - so even with this code-split, the component is still being imported from other imports - from a quick glance, the lack of tree-shaking may be due to [this SCSS import](https://github.com/argoproj/argo-ui/blob/5ff344ac9692c14dd108468bd3c020c3c75181cb/src/components/index.ts#L1) in `argo-ui`, which is a side-effect - a potential workaround may be to import all the components individually and then import the styles individually in our own code - started on this, did not finish, still draft Signed-off-by: Anton Gilgur <[email protected]>
- this should be pretty much all components except for the few context references Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
Signed-off-by: Anton Gilgur <[email protected]>
agilgur5
force-pushed
the
refactor-ui-code-split-xterm
branch
from
May 14, 2024 19:27
36586e4
to
9cb1645
Compare
Merged |
tczhao
approved these changes
May 24, 2024
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. It was a good read, I learned quite a bit.
This was referenced Jul 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partial fix for #12059
Motivation
After the past few code-splits (#12150, #12097, #12061)
xterm
was left as one of the largest deps in the main bundlexterm
is only used byargo-ui
in itsLogsViewer
component, which is only used by Workflows'FullHeightLogsViewer
componentxterm
itself: ~550KB / ~380KB minified / 84KB gzipped from main bundleargo-ui
: ~190KB / ~60KB minified / ~17KB gzipped from main bundlexterm
bundle though, so there is some overlapModifications
lazy load
LogsViewer
withinFullHeightLogsViewer
in order to code-split itwebpackPrefetch
magic comment as logs are very commonly used, at least in my experienceimport all
argo-ui
components individually, viaargo-ui/src/components/*
, instead of together viaargo-ui
orargo-ui/src/index
argo-ui
actually possible. the overallargo-ui
import as well as each component imports styles, which are side-effects that make tree-shaking not possibleargo-ui
components from the bundle that are not used by WorkflowsVerification
UI seems to work as before. Log viewing works as before.
Screenshot:
Bundle analysis
Before:
After:
Notes to Reviewers
The main change is to
full-height-logs-viewer.tsx
, the rest is just import changesI thought of doing all the tree-shaking within a shim import, e.g.
./argo-ui-shim.ts
, but then anything that imports that would get everything that the shim imports (due to its CSS import side-effects). Importing components individually where they're used allows for more splitting, particularly when more pages are split per UI: Code Split larger and/or less-used paths for smaller initial bundle #12059