Skip to content

Trim the UI boot bundle and fold lazy-only enum chunks into one - #34202

Merged
chirag-madlani merged 5 commits into
mainfrom
ui-trim-boot-bundle
Oct 1, 2026
Merged

chirag-madlani merged 5 commits into
mainfrom
ui-trim-boot-bundle

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The first page load downloaded code the first screen never runs, and the build emitted ~50 chunks that were nothing but a TS enum object each. This PR removes the first and prevents the second. antd is deliberately left alone; it is being removed separately.

Numbers (production build, brotli)

main this PR
Boot bundle (index.html) 1,098 KiB 1,029 KiB (−6%)
Total chunks 1,338 1,263
Enum-only chunks ~50 0 (build fails if one appears)

First-view JS (boot + the page's static chunks): sign-in 997 → 946, My Data 1,118 → 1,054, Settings 1,120 → 1,062, Explore 1,630 → 1,557, Table details 2,218 → 2,134, Glossary 2,386 → 2,302, Data quality 1,896 → 1,821 KiB.

Removed from boot

What Why it was there Fix
oidc-client (62 KiB) getCandidateUserManagerConfig (SSO Test Login only) did new WebStorageStateStore inside AuthProvider.util.ts Moved to SettingsSso/SsoTestLogin/candidateUserManagerConfig.ts; AuthProvider.util.ts keeps import type. OIDC providers still get it with their (already lazy) authenticator
analytics core AuthProvider imports resetWebAnalyticSession, which lived next to the analytics instance Moved to utils/WebAnalyticsSessionUtils.ts (needs only @analytics/session-utils)

stringToHTML / stripMarkdown / decodeHtmlEntities moved to utils/RichTextStringUtils.ts, and every caller in this repo imports them from there. StringUtils re-exports them for now because Collate imports stripMarkdown from it. That keeps dompurify / html-react-parser / remove-markdown in boot (~18 KiB) until the re-export is dropped after the Collate side is checked.

Enum chunks

TS enums are runtime objects, and quicktype emits 3,265 of them across 713 src/generated files. An enum module shared by several lazy routes became its own sub-1 KiB chunk.

  • Grouping: classifyChunk now puts lazy-only, import-free enum modules (src/generated, src/enums, *.enum.ts, *.interface.ts, types.ts) into one app-enums chunk.
  • Keeping boot unchanged: it checks the module graph (getModuleInfo) so anything the shell imports stays out. Import-free only, because a group also captures its members' dependencies.
  • Guard: the no-enum-only-chunks plugin fails the production build and lists each offending chunk with its source file. With the grouping switched off it reports 49; with it on, 0.

Also

vite build --mode analyze was unminified and bundled React's development build (NODE_ENV="analyze"), so bundle-stats.html reported roughly 2× the shipped size. It now builds exactly like production.

Not in this PR

An earlier revision also moved react-tour onto CJS lodash to get lodash-es out of main.js. Visual regression caught Explore crashing with py is not a function. main.js had been initialising the whole lodash-es namespace as a side effect; without that, some lodash-es modules that Rolldown wraps in lazy init were never initialised for the routes that use them. Reverted; worth revisiting separately.

Test plan

  • vite build passes on current main; enum guard passes
  • Guard negative check: grouping disabled → build fails listing 49 enum-only chunks with sources
  • Runtime binding check in headless Chromium: for each of 171 page chunks, load it in a fresh page and list exports that are still undefined. main and this PR both have exactly 176, all the same pre-existing vendor-antd binding. The reverted lodash change showed up to 8 extra per page, so the check catches this class of bug
  • jest --findRelatedTests on changed files: 1,217 suites pass; re-ran the StringUtils / SsoTestLogin / Explore / Topic / KnowledgeCard suites after the follow-up commit (240 tests)
  • UI checkstyle steps (organize-imports, eslint --fix, prettier) run locally on all changed files: clean
  • CI: visual regression, Collate build, Playwright

🤖 Generated with Claude Code

The boot bundle carried code the first screen never runs: all of lodash-es
(react-tour's UMD build requires "lodash", which the global alias turned into
the whole lodash-es namespace), oidc-client (one value import used only by SSO
Test Login), dompurify/html-react-parser/remove-markdown (StringUtils) and the
analytics core (AuthProvider only needs the session helper).

Lazy-only, import-free enum modules (src/generated, src/enums, *.enum.ts,
*.interface.ts, types.ts) now share one `app-enums` chunk instead of one
sub-1 KiB chunk each, and a build guard fails if an enum-only chunk appears
again. `--mode analyze` now builds like production so the treemap matches
what ships.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 14 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 14 warning(s) across 6 changed file(s).

Count Rule
12 react-hooks/exhaustive-deps
1 openmetadata-imports/no-api-calls-in-iteration
1 no-restricted-imports
All findings
Location Rule Message
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:300:9 react-hooks/exhaustive-deps The 'onLoginHandler' function makes the dependencies of useMemo Hook (at line 954) change on every render. Move it inside the useMemo callback. Alternatively, w
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:380:6 react-hooks/exhaustive-deps React Hook useCallback has missing dependencies: 'navigate', 'setApplicationLoading', 'setCurrentUser', and 'setIsAuthenticated'. Either include them or remove
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:435:9 react-hooks/exhaustive-deps The 'resetUserDetails' function makes the dependencies of useMemo Hook (at line 954) change on every render. To fix this, wrap the definition of 'resetUserDetai
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:552:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'handleStoreProtectedRedirectPath', 'resetUserDetails', and 'setIsAuthenticated'. Either include them or remove t
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:554:9 react-hooks/exhaustive-deps The 'handleFailedLogin' function makes the dependencies of useMemo Hook (at line 954) change on every render. Move it inside the useMemo callback. Alternatively
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:610:5 react-hooks/exhaustive-deps React Hook useCallback has missing dependencies: 'authConfig?.provider', 'handledVerifiedUser', 'navigate', and 'resetUserDetails'. Either include them or remov
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:660:9 react-hooks/exhaustive-deps The 'initializeAxiosInterceptors' function makes the dependencies of useMemo Hook (at line 954) change on every render. To fix this, wrap the definition of 'ini
🟡 src/components/Auth/AuthProviders/AuthProvider.tsx:943:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'fetchAuthConfig'. Either include it or remove the dependency array.
🟡 src/components/Certification/Certification.component.tsx:129:9 react-hooks/exhaustive-deps The 'handleScroll' function makes the dependencies of useMemo Hook (at line 235) change on every render. Move it inside the useMemo callback. Alternatively, wra
🟡 src/components/Certification/Certification.component.tsx:271:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'currentCertificate' and 'getCertificationData'. Either include them or remove the dependency array. If 'setSelec
🟡 src/components/KnowledgeCenter/KnowledgeCard/KnowledgeCard.tsx:240:9 react-hooks/exhaustive-deps The 'handleToggleDelete' function makes the dependencies of useCallback Hook (at line 258) change on every render. Move it inside the useCallback callback. Alte
🟡 src/components/Topic/TopicVersion/TopicVersion.component.tsx:206:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'dataProducts', 'domains', and 't'. Either include them or remove the dependency array.
🟡 src/pages/ContextCenterPage/ContextCenterAIContextPage/ContextCenterAIContextPage.tsx:62:40 openmetadata-imports/no-api-calls-in-iteration Avoid issuing one API request per item. Fetch at the data owner, use a bulk endpoint, or use useQueries with an intentional concurrency policy.
🟡 src/utils/DataAssetsVersionHeaderUtils.tsx:17:1 no-restricted-imports '../assets/svg/external-links.svg' import is restricted from being used by a pattern. Do not import SVG icons directly from assets/ paths; use the designated ab

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 74%
74.51% (111546/149689) 59.83% (68323/114191) 61.35% (22751/37083)

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ SSO Login Nightly — PASSED

View workflow run · Commit b3e91b5

Provider Status Pass Fail Flaky Skip Duration
basic ✅ pass 23 0 0 0 6m 38s
ldap ✅ pass 7 0 0 0 1m 00s
keycloak-oidc-confidential ✅ pass 10 0 0 0 1m 43s
keycloak-oidc-public ✅ pass 9 0 0 0 1m 20s
msal-mock ✅ pass 6 0 0 0 0m 56s
auth0-mock ✅ pass 6 0 0 0 1m 03s
okta ⏩ skipped - - - - -
keycloak-azure-saml ✅ pass 18 0 0 0 6m 13s
keycloak-azure-saml-crosssite ⏩ skipped - - - - -

Totals: 79 passed · 0 failed · 0 flaky · 0 skipped · duration 18m 56s

chirag-madlani and others added 2 commits September 30, 2026 12:00
…tringUtils

#34244 changed stripMarkdown in StringUtils while this branch moved it to
RichTextStringUtils. Keep the move, port the HTML block-boundary handling, and
point the new DataProductDescriptionField caller at RichTextStringUtils.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
vite.config.ts now holds configuration only. The custom plugins live in
vite/plugins.ts and the chunk classifier (with its module-graph helpers) in
vite/chunks.ts. Build output is byte-identical.

vite/** is added wherever CI lists vite.config.ts (dist cache key,
visual-regression and bundle-input path filters, Playwright impact map), so a
plugin change still invalidates the cache and triggers those jobs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
#34141 removed the vendor-untitled-icons chunk group and the icon barrel
rewrite from vite.config.ts; this branch had moved both into vite/chunks.ts and
vite/plugins.ts, so drop them there. KnowledgeCard keeps upstream's
getSafeHttpUrl (StringUtils) alongside stripMarkdown (RichTextStringUtils).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk · The UI bundle graph and SSO test-login configuration alter bounded runtime behavior.

Trims the boot bundle by 6% (69 KiB) by removing oidc-client and analytics core, and consolidates ~50 enum-only chunks into a single app-enums chunk with a build guard. Moves stringToHTML, stripMarkdown, and decodeHtmlEntities to RichTextStringUtils.ts with StringUtils re-exporting for Collate compatibility, keeping dompurify, html-react-parser, and remove-markdown in boot temporarily (~18 KiB). No issues found.

✅ 1 closed
✅ Performance: StringUtils re-export pulls dompurify/html-parser back into boot

📄 openmetadata-ui/src/main/resources/ui/src/utils/StringUtils.ts:493-499 📄 openmetadata-ui/src/main/resources/ui/src/utils/RichTextStringUtils.ts:13-15
The PR moved stringToHTML/stripMarkdown into RichTextStringUtils.ts so the shell would stop loading dompurify, html-react-parser and remove-markdown. The new export { ... } from './RichTextStringUtils' in StringUtils.ts makes RichTextStringUtils a static dependency of StringUtils again, and the shell still imports StringUtils (for example BasicAuthProvider.tsx). Rollup only drops an unused re-export when the target module and its dependencies have no side effects. dompurify runs createDOMPurify() at module top level and reads window, so the bundler keeps it and puts it in the entry chunk. That likely undoes this part of the boot-size savings. Moving decodeHtmlEntities also means any caller that imports it from StringUtils now goes through this re-export. Suggested fix: remove the re-export from StringUtils and give Collate a separate compat module, or point Collate at RichTextStringUtils directly. Then run the production build again and confirm dompurify is not in the index.html chunk.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-01T11:58:30Z)

Blocked the queue: playwright-summary

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants