Skip to content

UI: Code Split larger and/or less-used paths for smaller initial bundle #12059

@agilgur5

Description

@agilgur5

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:

Also, some pages could be good to code-split by default

Checklist

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):

  1. code split deps

    1. monaco-editor (et al): refactor(ui): code-split gigantic Monaco Editor dep #12150
    2. moment-timezone: refactor(ui): replace moment-timezone with native Intl #12097
    3. swagger-ui-react (et al): build(ui): code-split ApiDocs and Reports components #12061
    4. xterm: refactor(ui): code-split out large xterm dep #12158
    5. moment: refactor(deps): remove moment dep and usage #12611
    6. chart.js: build(ui): code-split ApiDocs and Reports components #12061
    7. react-markdown (+ remark-gfm + etc): fix(ui): code-split markdown title + desc, fix row linking, etc #12580
    8. react-datepicker (+ date-fns + react-popper + etc):
    9. cron-parser (+ luxon):
  2. code split pages

    1. ApiDocs: build(ui): code-split ApiDocs and Reports components #12061
    2. Reports: build(ui): code-split ApiDocs and Reports components #12061
    3. event-sources:
    4. sensors:
    5. event-flow:
    6. cron-workflows:
    7. workflow-templates:
    8. 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 👍.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/uisolution/suggestedA solution to the bug has been suggested. Someone needs to implement it.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions