Repository navigation
Commit 2b57044
perf(console): the first load stops downloading the grid and detail packages (#36336)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1qGnTYLQs3EtmtCmjrcfCe)_
Fixes #33581
Clause-②: yes (widening) — one new published `exports` subpath,
`@object-ui/plugin-detail/core`; nothing removed or renamed, the package
root exports the same names as before
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:控制台第一次打开任何页面时少下载约 165 KB(压缩后,约为首屏下载量的
8%);首页、仪表盘、列表页、记录页、记录浮层画面和操作都不变。
- 为什么做:控制台首屏提速——过去每个页面都要先下载表格和详情组件,再去读数据。
- 出错会怎样:若某处漏改,表格或详情块第一次出现时会多等一次加载,画面内容不变;本改动可以直接撤回。
- 要你做什么:无。
## What changes
On every route the console used to download the `plugin-grid` chunk (all
of `@object-ui/plugin-grid` plus 77 `@object-ui/plugin-detail` modules,
183 KB gzip) before its first data read. That chunk now leaves the eager
closure; the list and record routes fetch it with their own route
chunks, and any other surface fetches it the first time it draws a grid
or a detail block.
- **`@object-ui/plugin-detail/core`** (new subpath, ESM only, like the
other `/core` subpaths): the pure helpers the console shell needs on
every page, registering nothing. Names: `isRefusedFeedRead`,
`relatedListEntryNames`, `RELATED_ARRANGEMENT_RECORD_VERSION`,
`relatedArrangementFromRecord`, `relatedArrangementToRecord`,
`deriveFieldGroupDetailSections`, `deriveHighlightFields`,
`resolveDetailSections`, `isWideFieldType`, `prefetchRelatedCounts`,
`relatedCountTargetsIn`, `COMPACT_RELATED_ROWS`,
`normalizeRelatedListSort`, `seedQueueClaimDecision`,
`seedRecordFieldAccess`, `seedRecordVerdict`, type `RelatedArrangement`.
The root still exports all of them. `normalizeSortSpec` moved verbatim
from `RelatedList.tsx` to `relatedListSort.ts` so the subpath does not
reach the component.
- **Published ESM build of plugin-detail**: a second pass
(`vite.es.config.ts`) emits `index` and `core` in one pass with
`preserveModules`, so the record-page caches the `/core` seeds write are
the same module instances the root's hooks read. File names match the
package's existing `sideEffects` spellings (`./dist/queueClaim.js` and
friends). The UMD build is unchanged.
- **Console shell** (`@object-ui/app-shell`): eight modules take the
helpers from `/core`. The record pointer card's key fields and the
approval decision's child tables draw `HeaderHighlight` / `RelatedList`
through `lazy()` wrappers (`lazyDetailSurfaces.tsx`); the pointer card
starts the chunk load beside its record read (no timeout raised). A
wrapper mounted after the chunk loaded draws without suspending.
- **Console** (`register-plugins.ts`): the bare `import
'@object-ui/plugin-grid'` / `import '@object-ui/plugin-detail'` become
`registerLazy` stubs for every tag the two packages register, with the
namespaces their registrations declare: `object-grid`, `view:grid`,
`detail-view`, `detail-section`, `view:detail`, and the eleven `record:`
blocks (`details`, `related_list`, `highlights`, `activity`, `chatter`,
`discussion`, `path`, `quick_actions`, `history`, `reference_rail`,
`alert`). `App.tsx` loads the dev-only row-actions page lazily.
`vite.config.ts` gets a `plugin-detail-core` chunk group so the
subpath's closure does not fall into the `plugin-grid` group.
The card's other two slices were already in place on main: `plugin-form`
and `plugin-view` were lazy behind their `/core` subpaths (#34176), and
`RecordDetailView` / `ObjectView` sat behind the lazy route boundary
(#33677). Step 1 below shows it.
### Step 1: main `29556850`, what held each package eager
Eager closure 2,042,500 B gzip, 105 of 2551 chunks. Largest eager
chunks: `vendor-objectstack` 673,811 · `ui-components` 351,125 ·
**`plugin-grid` 183,395** · `index` 135,521 · `framework` 88,559 ·
`vendor-react` 81,619 · `i18n-locale-en` 66,610 · `vendor-radix` 59,724
· `src` 43,005 · `infrastructure` 37,749.
| Package | Eager on main? | Edges holding it |
|---|---|---|
| plugin-grid (chunk = 74 grid + 77 detail modules) | yes, 183,395 B |
`register-plugins.ts` bare imports of grid and detail; `App.tsx` to
`dev/DevRowActions.tsx` (ObjectGrid); app-shell named imports from the
plugin-detail root in `sharedUserFeeds`, `deriveRelatedLists`,
`workspacePreference`, `recordDetailSections`, `recordDrawerStack`,
`recordPagePayload`, `SubmittedRecord` (RelatedList),
`RecordPreviewCard` (HeaderHighlight) |
| plugin-form | no (only `plugin-form-core`, 6,652 B) | none; lazy since
#34176 |
| plugin-view | no (only `plugin-view-core`, 1,789 B) | none; lazy since
#34176 |
| RecordDetailView | no | none; behind the lazy route boundary since
#33677 |
### Before / after
| Build | Eager gzip bytes | Eager chunks | grid / form / detail /
RecordDetailView eager |
|---|---|---|---|
| main `337f435c` | 2,043,450 | 105 | `plugin-grid` 183,666 |
| this branch `feb24f53` (same base) | 1,874,495 (**−168,955**) | 105 |
none; `plugin-detail-core` 15,702 joins |
| this branch head `58e12ffd` (main `99fbaa6d` merged) | 1,875,181 | 105
| none (`plugin-detail-core` 15,702, `plugin-form-core` 6,654,
`plugin-view-core` 1,789) |
The head row includes main's own drift between the two merges (for
example `ui-components` +662 B). `check:eager-closure` on head: exit 0,
1831.2 KB, headroom 600.4 KB.
Lazy chunks, gzip (python gzip -6, main `337f435c` vs head `feb24f53`):
`plugin-grid` 183,368 / 188,399 · `plugins-views` 62,376 / 55,420 ·
`plugin-form` 47,198 / 47,212 · `plugin-view` 19,846 / 19,846 ·
`RecordDetailView` 29,554 / 30,003. The grid chunk grows by the detail
renderers that left `plugins-views`.
## Tests
Local, scoped (CI runs the full suites):
- Before the last main merge, head `feb24f53`: 406 test files (app-shell
tests of every touched module, all console `__tests__`, plugin-detail,
the `ui/scripts` side-effects and declared-lazy-views tests): 405
passed, 1 failed (`RecordPreviewCard.test.tsx`, the highlight strip
under the new lazy wrapper). Fixed in `feb24f53`; that file plus the
pins rerun: 13 files / 149 tests passed.
- `type-check` for `@object-ui/plugin-detail`, `@object-ui/app-shell`,
`@object-ui/console`: exit 0 (on `feb24f53` and again on `58e12ffd`).
eslint on the changed files: exit 0. `vitest` over `scripts/`: 5127
tests passed.
- Head `58e12ffd` (after merging main `99fbaa6d`): full turbo build exit
0, eager-closure budget exit 0, type-checks exit 0. The scoped test
rerun on this head (493 files) was still running when this body was
written (handover cut-off): **NOT MEASURED on `58e12ffd`**, CI is the
reading.
Pins:
`ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts`
now also holds `plugin-detail/core` (names, no registrations) and the
eager modules (App, register-plugins, the eight shell modules,
`lazyDetailSurfaces`) to subpath-or-type-only imports of plugin-detail
and plugin-grid.
Ablations (one-shot, on committed head `feb24f53`, each restored with
`git checkout HEAD --`, blob hash compared, `git diff HEAD` empty):
1. `recordPagePayload.ts` back to the plugin-detail root import: all
three pin tests red (offender listed, importer floor 8 of 9).
2. bare `import "@object-ui/plugin-grid"` added to
`register-plugins.ts`: the bare-import pin red ("bare import from
'@object-ui/plugin-grid'"). The first attempt at this ablation was a
no-op (the replacement contained the anchor; the replace tool refused
it); redone with a different quote spelling.
## Acceptance notes
- Real browser (Chromium, showcase app, signed in as admin; the same
server served the `337f435c` console build and then this branch's), five
routes: home, a dashboard, an object list, a record page, a record
overlay. All five drew on both builds with the same text, no page errors
beyond a 404 the home page shows on both, no failed requests.
- main fetched `plugin-grid` 40–75 ms after navigation on every route,
before the first data read (667–1144 ms).
- this branch: home and dashboard never fetch `plugin-grid`; the list
fetches it at 1032 ms beside `ObjectView` (1050); the record page at 882
ms beside `RecordDetailView` (900); the overlay at 1027 ms.
- JS requests per route (main / head): home 105 / 105, dashboard 143 /
140, list 227 / 201, record 171 / 156, overlay 229 / 203.
- No carve-out naming `plugin-grid` is added to the eager-closure budget
check, and none is owed. New gates are "no" by default unless the
maintainer names one, and this class is already held by two things: the
source pin `pluginCoreSubpaths-33581` (ablation 2 turns it red) and the
total `check:eager-closure` budget.
- `plugin-detail-core` (15,702 B gzip at this head) also holds
`ConcurrentUpdateDialog`, because `isConcurrentUpdateError` is in the
same module. That share of the chunk is not measured on its own.
## Verification
Read first:
1. `ui/apps/console/src/register-plugins.ts` — a tag the two packages
register but the stubs miss would draw an unresolved component on first
use.
2. `ui/packages/plugin-detail/vite.es.config.ts` + `package.json` — the
published ESM layout changes to one file per module; the seed caches
depend on it.
3. `ui/packages/app-shell/src/views/lazyDetailSurfaces.tsx` — first-draw
loading of the two shell detail components.
Two-minute check: `pnpm --filter @object-ui/console build`, then `node
-e 'const
j=require("./ui/apps/console/dist/eager-closure.json");console.log(j.eagerGzipBytes,
j.files.filter(f=>/^(plugin-|RecordDetailView|plugins-)/.test(f.name)).map(f=>f.name))'`
from the repo root. Expected: about 1,875,000, and only
`plugin-chatbot-core`, `plugin-detail-core`, `plugin-form-core`,
`plugin-view-core`, with no `plugin-grid`.
Gates: `node scripts/pm/dispatch-gates.mjs --commands` derived 60
families on `f3214b28`; all 60 ran locally and `--ran` reconciled 60 of
60, 0 NOT MEASURED, exit 0. First runs of four families read wrong and
were rerun after a full build: dts-closure exit 1 (console `.d.ts` not
built yet), dual-build-cjs-loads exit 3 (prerequisite unbuilt),
query-options-erasure 124 (my own 300 s timeout), type-check-debt (I
stopped its lock-held rebuild); all four reran to exit 0. UI extras:
`check:side-effects-array` 0, `check:sdui-registration-pins` 0,
`check:eager-closure` 0, `vite-declared-lazy-views` passed inside the
builds (13 of 13 lazy). The gate set was not rerun on `58e12ffd` (a
clean main merge); the PR check-runs are the reading there.
Written by `repo:objectstack#4 · os-project-manager ·
session_01FEkQ5kt9AD1TPLy7Y9oa9D`
(https://claude.ai/code/session_01FEkQ5kt9AD1TPLy7Y9oa9D).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5kt9AD1TPLy7Y9oa9D -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1d72662 commit 2b57044
24 files changed
Lines changed: 369 additions & 55 deletions
File tree
- .changeset
- ui
- apps/console
- src
- packages
- app-shell/src
- __tests__
- hooks
- utils
- views
- approval-decision
- record-preview
- plugin-detail
- src
- scripts/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
481 | 483 | | |
482 | 484 | | |
483 | 485 | | |
484 | | - | |
| 486 | + | |
485 | 487 | | |
486 | 488 | | |
487 | 489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 28 | | |
35 | 29 | | |
36 | 30 | | |
| |||
92 | 86 | | |
93 | 87 | | |
94 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
95 | 138 | | |
96 | 139 | | |
97 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| 630 | + | |
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| |||
1529 | 1530 | | |
1530 | 1531 | | |
1531 | 1532 | | |
1532 | | - | |
| 1533 | + | |
| 1534 | + | |
1533 | 1535 | | |
1534 | 1536 | | |
1535 | 1537 | | |
| |||
1549 | 1551 | | |
1550 | 1552 | | |
1551 | 1553 | | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
1552 | 1560 | | |
1553 | 1561 | | |
1554 | 1562 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
| |||
100 | 107 | | |
101 | 108 | | |
102 | 109 | | |
103 | | - | |
| 110 | + | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| |||
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
112 | 122 | | |
113 | 123 | | |
114 | 124 | | |
115 | 125 | | |
| 126 | + | |
| 127 | + | |
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
| |||
127 | 139 | | |
128 | 140 | | |
129 | 141 | | |
130 | | - | |
| 142 | + | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
| |||
139 | 151 | | |
140 | 152 | | |
141 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
142 | 163 | | |
143 | 164 | | |
144 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
608 | 609 | | |
609 | 610 | | |
610 | 611 | | |
611 | | - | |
| 612 | + | |
612 | 613 | | |
613 | 614 | | |
614 | 615 | | |
| |||
0 commit comments