Skip to content

perf(console): make the /docs portal genuinely lazy - #5485

Merged
os-support-ai merged 2 commits into
mainfrom
claude/issue-5467-console-lazy-page-imports
Aug 21, 2026
Merged

perf(console): make the /docs portal genuinely lazy#5485
os-support-ai merged 2 commits into
mainfrom
claude/issue-5467-console-lazy-page-imports

Conversation

@os-support-ai

Copy link
Copy Markdown
Collaborator

Fixes #5467

AppContent.tsx lazy-imports DocsLayout / DocsSlug / DocPage for the app-scoped /apps/:packageId/docs tree (ADR-0048). App.tsx imported the same three statically for the platform portal at /docs (ADR-0046 section 6), so all three sat in the eager graph regardless and the import() moved nothing — three INEFFECTIVE_DYNAMIC_IMPORT warnings on every vite build.

Which side was fixed, and why

Both route trees are live, so neither set of imports is dead code:

  • App.tsx — the platform docs portal at /docs (ADR-0046 section 6): DocsLayout with DocsIndex, DocsSlug, DocPage.
  • AppContent.tsx — the app-scoped package docs at /apps/:packageId/docs (ADR-0048): the same DocsLayout / DocsSlug / DocPage, with AppDocsIndex at the index slot.

Deleting the lazy imports in AppContent.tsx would make the intent honest and change nothing: the pages are already eager, so that route is the one paying, not the one deciding. The laziness was written on purpose and AppContent applies it uniformly to all thirteen of its pages — nothing on a normal console page load visits docs, and DocPage is the only console-owned module that reaches @object-ui/plugin-markdown. So App.tsx is the side that was wrong, and it now reaches all four docs pages through lazy() behind Suspense, in exactly the shape AppContent.tsx already uses.

DocsIndex joins them even though it carried no warning — AppContent renders AppDocsIndex at that slot, so nothing imported DocsIndex dynamically. Left static it alone would keep DocShell, use-book-data and book-nav eager, and the portal would only half-leave the closure.

Measured

Gauge: apps/console/dist/eager-closure.json, added by #5324 / PR #5466. Both legs exited 0 — the warning count was never read from a build that died. Final numbers taken from the build on f9bbd4144, the branch HEAD.

metric before after delta
INEFFECTIVE_DYNAMIC_IMPORT warnings 46 44 −2
eager closure, gzipped bytes 3,881,609 3,870,058 −11,551 (−0.30%)
eager chunks 58 / 507 52 / 508 −6

Warning composition, which is the counter-probe on the zero: the three console-page warnings go 3 to 0, while the 43 packages/fields warnings of #5325 stay at 43 in both legs. A grep that had stopped matching, or a build that had died, would have taken those 43 with it.

Six chunks leave the eager closure:

chunk gzipped
src 129,555
plugin-markdown 4,212
CreateViewDialog 3,617
use-book-data 1,966
DocShell 476
componentRegistry 99

src is not a saving: rolldown folds it into the entry chunk instead of dropping it, which is why the entry chunk grows from 25,910 to 154,378 gzipped bytes while the closure as a whole shrinks. The entry stays far under that budget's 350 KB line, and scripts/check-eager-closure-budget.mjs passes with headroom up from 78.4 KB to 87.8 KB. Worth knowing before reading the Bundle Analysis comment, where the entry-chunk number jumps six-fold and the closure number is the one that matters.

The saving is 0.30%, not 4% — and the reason is #5325

vendor-markdown does not move: 164,708 gzipped bytes, still eager. Three eager chunks import it statically and only one of them was this portal:

  • plugin-chatbot, which reaches it directly and is itself eager;
  • ui-components, because packages/fields' MarkdownContentReact.lazy in source — is folded into that eagerly imported chunk by the advancedChunks group claiming every packages/fields module.

That second one is exactly the mechanism #5325 measured, arriving from a different direction. This card's hypothesis — that apps/console/src is claimed by no group and so a genuinely lazy page can get its own chunk — held: the console's own modules did cleave. What did not follow is the markdown vendor payload, because the console pages were never its only eager owner. Non-zero, but an order of magnitude below what the file list suggests.

Reverse verification

Ablation: git checkout origin/main -- apps/console/src/App.tsx, both legs re-run, direction predicted before running.

leg predicted observed
App.docsPortalLazy.test.tsx red at expect(loaded.DocsLayout).toBeUndefined(), positive control still green red, exactly there: expected true to be undefined at line 151; the SharedRecordPage control on line 149 passed first
vite build warnings back to 46 with the three docs ones returning; closure back to 3,881,609 B / 58 chunks 46 warnings, the three docs ones back, 3,881,609 B / 58 chunks, exit 0

Restored with git checkout HEAD -- apps/console/src/App.tsx; git status --porcelain empty and git hash-object of the working file equals the committed blob 68d115b3, so the restore is byte-identical rather than merely clean-looking.

A warning appears that was not there before, and it is not a regression

The build now reports one warning it did not report before:

packages/app-shell/src/index.ts is dynamically imported by src/registerStudioComponents.tsx but also statically imported by src/App.tsx, src/AppContent.tsx, ...

That file is byte-identical to main in this branch (git diff origin/main...HEAD touches it not at all), and its laziness was already dead there: it statically imports registerAppComponent from the same barrel on line 19 while lazy()-importing the barrel on line 22, and App.tsx on main already imports BuilderLanding statically from it. The ablation confirms the direction — with the fix removed the warning goes away again, so what changed is reportability, not the defect: once the docs pages leave, src folds into the entry chunk and rolldown can see that this import() cannot move anything. Filed separately rather than folded in; the correct shape there is a decision (drop the lazy(), or stop importing BuilderLanding statically in App.tsx), not a mechanical edit.

Tests

apps/console/src/__tests__/App.docsPortalLazy.test.tsx pins laziness as a runtime property, not as a spelling. A vi.mock factory runs the first time its module is imported, so the flags it sets record when each page entered the graph: a static import in App.tsx sets the flag while App.tsx is evaluated, before any test body runs. A regex over the source would pin one spelling of the mistake; this pins the mistake.

Two counter-probes, because "never loaded" is what a flag that can never be set also looks like: SharedRecordPage is a live positive control (still statically imported, so its flag must already be set), and visiting /docs must flip the layout's flag and render it through the Suspense boundary. DocsSlug and DocPage must still be unloaded afterwards, since /docs matches neither.

internalFormShell.test.tsx's @object-ui/app-shell mock gains LoadingScreen. This is required, not optional: App.tsx's route elements are constructed when App renders, so the Suspense fallback's export is read even by a test that never visits /docs, and without it both of its tests died on the vitest mock proxy. That failure was observed before it was fixed.

Surface note: the card's declared file surface was apps/console/src/{App,AppContent}.tsx plus src/pages/**. The two test files above sit in src/__tests__/ — the new one is a new path that cannot collide, and the mock repair is mandated by this change rather than chosen.

Verification run on f9bbd4144

pnpm exec vitest run apps/console/ 58 files, 673 tests, 0 failed, 0 skipped
pnpm --filter @object-ui/console type-check pass
pnpm --filter @object-ui/console lint 0 errors (202 pre-existing warnings, none in changed files)
check:eager-closure pass, 3779.4 KB against a 3867.2 KB budget
check:control-bytes pass, 4531 files scanned
check:self-import, check:esm-specifiers, check:phantom-deps pass
check-changeset-presence, check-changeset-no-major pass

Changeset: .changeset/console-lazy-docs-portal-5467.md (@object-ui/console: patch).


Generated by Claude Code

claude added 2 commits August 21, 2026 02:12
App.tsx statically imported DocPage / DocsSlug / DocsLayout while
AppContent.tsx lazy-imported the same three for the app-scoped
/apps/:packageId/docs tree, so all of them sat in the eager graph and
the import() moved nothing -- three INEFFECTIVE_DYNAMIC_IMPORT warnings
on every vite build.

App.tsx now reaches all four docs pages through lazy() behind Suspense,
matching AppContent's existing pattern. DocsIndex joins them because,
left static, it alone would keep DocShell / use-book-data / book-nav
eager.

Measured (both builds exit 0): warnings 46 -> 44, eager closure
3,881,609 -> 3,870,058 gzipped bytes across 58 -> 52 chunks.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RV6yuVCxymHYE16PL9vQkE
…(objectui#5467)

App.docsPortalLazy.test.tsx measures WHEN each docs page enters the module
graph, not how App.tsx spells its imports: a vi.mock factory runs on first
import, so a static import sets the flag while App.tsx is evaluated, before
any test body runs.

Two counter-probes keep "never loaded" from passing vacuously -- the still
statically imported SharedRecordPage is a live positive control, and
visiting /docs must flip the layout's flag and render it through the
Suspense boundary.

internalFormShell.test.tsx's @object-ui/app-shell mock gains LoadingScreen:
App.tsx's route elements are built when App renders, so the Suspense
fallback's export is read even by a test that never visits /docs. Without
it both of its tests died on the vitest mock proxy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RV6yuVCxymHYE16PL9vQkE
@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 52 chunks) 3781.3 KB 3867.2 KB
Main entry chunk (gzip) 151.1 KB 350 KB
Entry file index-DKSrq6u8.js
Status PASS

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 10.04KB 3.72KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 29.34KB 7.05KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 6.35KB 2.43KB
auth (index.js) 2.77KB 1.22KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.02KB 0.89KB
auth (useIsWorkspaceAdmin.js) 3.04KB 1.45KB
collaboration (CommentThread.js) 26.08KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 506.94KB 113.63KB
core (index.js) 4.11KB 1.62KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 159.80KB 44.34KB
fields (index.js) 237.21KB 59.50KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.28KB 1.75KB
i18n (index.js) 3.44KB 1.39KB
i18n (pickLocalized.js) 7.22KB 3.08KB
i18n (provider.js) 23.13KB 7.63KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 30.51KB 7.57KB
i18n (useSafeTranslation.js) 7.77KB 3.13KB
layout (index.js) 38.95KB 10.97KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.55KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useResponsiveConfig.js) 1.37KB 0.63KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 9.35KB 3.31KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 4.42KB 1.42KB
permissions (evaluator.js) 5.12KB 1.74KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 1.81KB 0.83KB
plugin-ai (index.js) 15.75KB 3.80KB
plugin-calendar (index.js) 46.62KB 12.83KB
plugin-charts (index.js) 64.75KB 18.37KB
plugin-chatbot (index.js) 181.21KB 43.14KB
plugin-dashboard (index.js) 128.51KB 32.94KB
plugin-designer (index.js) 212.39KB 42.83KB
plugin-detail (index.js) 242.15KB 60.89KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 124.40KB 30.26KB
plugin-gantt (index.js) 164.10KB 39.87KB
plugin-grid (index.js) 200.75KB 54.24KB
plugin-kanban (index.js) 52.93KB 14.60KB
plugin-list (index.js) 111.64KB 27.13KB
plugin-map (index.js) 20.08KB 6.62KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 43.49KB 11.93KB
plugin-timeline (index.js) 26.68KB 7.66KB
plugin-tree (index.js) 8.50KB 2.88KB
plugin-view (index.js) 84.52KB 20.67KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 36.10KB 12.26KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.33KB 0.69KB
react (schema-input.js) 1.45KB 0.83KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 5.41KB 2.34KB
sdui-parser (index.js) 4.77KB 2.16KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 10.76KB 3.17KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 6.92KB 2.40KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 3.08KB 1.53KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 2.59KB 1.31KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@os-support-ai
os-support-ai marked this pull request as ready for review August 21, 2026 02:54
@os-support-ai
os-support-ai added this pull request to the merge queue Aug 21, 2026
Merged via the queue into main with commit fb934fb Aug 21, 2026
23 checks passed
@os-support-ai
os-support-ai deleted the claude/issue-5467-console-lazy-page-imports branch August 21, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apps/console: three lazy page imports in AppContent.tsx are defeated by static imports in App.tsx — 3 INEFFECTIVE_DYNAMIC_IMPORT warnings per build

2 participants