-
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
UI: Code Split larger and/or less-used paths for smaller initial bundle #12059
Comments
Ran Observations:
|
Argo CD appears to do code-splitting in one place already -- for I believe both CD and Workflows only do very minimal code editing of YAML files, so we likely could use less featured editors as well (YAML is a lot simpler than a full language). |
Tiny modification, in my above comment I accidentally analyzed a development bundle (as visible in Here's an analysis of a production bundle: Main differences are:
|
Also thought I'd output some Webpack performance hints/warnings (after #12150):
Webpack's perf hints suggest going down to ~244KB minified. In any case, I'm still focusing on the large deps first and foremost, but thought I'd note that down for reference |
Is there anything that could prevent us from upgrade |
That would only solve the pages portion of this issue, but not the deps portion (some large deps are used in multiple pages/routes). Ultimately, that's also just short-hand, so just simplifies that part of the issue But yes, there's a chicken-and-egg problem with upgrading |
Summary
Instead of having all the UI pages in one bundle, we can code split out certain pages that are either quite large (e.g. have a lot of code or deps) or less-used.
Use Cases
Implementation Details
Nowadays, React supports loading components async with the built-in
lazy
function, which you normally pass a dynamic import into. Webpack will automatically code-split dynamic imports.Two components that I think might be ripe for code-splitting are:
swagger-ui-react
to latest 4.x.x #12058 and webpage remains blank for an extended period due to slow network #11970) that are used pretty infrequently, contain a wholeswagger-ui
in it and the Swagger file itselfmonaco-editor
Also, some pages could be good to code-split by default
Reports
to functional component and split files #11794Checklist
EDIT: This was added after a lot of analysis and work below to keep track of things, was not part of the original issue.
In order of most impact to the bundle and most splittable (some are used in many places and so are harder to split):
code split deps
monaco-editor
(et al): refactor(ui): code-split gigantic Monaco Editor dep #12150moment-timezone
: refactor(ui): replacemoment-timezone
with nativeIntl
#12097swagger-ui-react
(et al): build(ui): code-splitApiDocs
andReports
components #12061xterm
: refactor(ui): code-split out largexterm
dep #12158moment
: refactor(deps): removemoment
dep and usage #12611chart.js
: build(ui): code-splitApiDocs
andReports
components #12061react-markdown
(+remark-gfm
+ etc): fix(ui): code-split markdown title + desc, fix row linking, etc #12580react-datepicker
(+date-fns
+react-popper
+ etc):cron-parser
(+luxon
):code split pages
ApiDocs
: build(ui): code-splitApiDocs
andReports
components #12061Reports
: build(ui): code-splitApiDocs
andReports
components #12061event-sources
:sensors
:event-flow
:cron-workflows
:workflow-templates
:cluster-workflow-templates
:Trade-offs
Note that code-splitting is not without its trade-offs as more bundles can have downsides. In particular if those bundles are very small. In this case I think the pros outweigh the cons for certain pages (Swagger UI almost certainly), but may need some more testing for other pages.
Message from the maintainers:
Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.
The text was updated successfully, but these errors were encountered: