Repository navigation
Commit 571cf90
perf(console): plugin-form and plugin-view helpers come from side-effect-free /core subpaths (#34176)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9QjKmMVoDWtE45ELv1652Kd)_
Part of #33581
Clause-②: yes (widening) — two new published `exports` subpaths,
`@object-ui/plugin-form/core` and `@object-ui/plugin-view/core`; nothing
removed or renamed, the package roots export the same names as before
Metadata-protocol: none
## 维护者速读
- 做了什么:控制台首屏不再下载表单包和视图包。两个包各新增一个不注册任何东西的 `/core`
子路径,壳层只从它取辅助函数;表单和视图组件在第一次画出时才加载。
- 效果:首屏 eager 闭包 gzip 从 1,961,037 B 降到 1,909,225 B(−51,812 B,约
−2.6%);plugin-form(44 KB)、plugin-view(16 KB)两块离开首屏,换进来两个小块(6.4 KB + 1.8
KB)。
- 用户可见的变化:一个会话里第一次打开记录表单、动作弹窗表单或流程表单步骤时,要等表单块下载完才显示;其余页面画出的内容不变。
- 没做的:卡里第 2 项(plugin-detail 的 11 处直取)不在本 PR。原因是 plugin-detail
有带订阅的模块级缓存,单独打一个 `/core`
包会在发布包里造出第二个实例,种子写不到根入口那一份;要改发布包的构建形状,需要席位定。plugin-grid 因此仍在首屏。
- 风险:公开面只加不减(两个新子路径)。九个测试套件原来顺着首屏图读到表单注册,需要改。另有两个 sideEffects
门禁测试对“无副作用的次入口”自相矛盾,做了窄口对齐,这超出了卡上写的文件范围。以上都逐个列在下面。
- 需要你做的:无;按惯例走契约复审后落地。
## What changes
**Two side-effect-free subpaths.** `@object-ui/plugin-form` and
`@object-ui/plugin-view` register their renderers when their root entry
is evaluated, and each root reaches every surface of its package. One
pure helper imported from a root kept the whole package in the console's
first load. Each package now publishes `/core` (ESM only, built by a
second `vite build --config vite.core.config.ts` pass, the
`@object-ui/plugin-chatbot/core` precedent), and it registers nothing:
- `plugin-form/core` (`src/core.ts`): `filterSystemFields`,
`isAutoGeneratedFieldType`, `isWideFieldType`, `inferColumns`,
`containerGridColsFor`, `resolveInlineMode`,
`omitServerResolvedDefaults`, `optionListDefault`,
`resolveSectionGroupReferences`, `useInitialFieldFocus`, plus their
parameter types.
- `plugin-view/core` (`src/core.ts`): `deriveRecordSurface`,
`deriveRecordFlowSurface`, `overlayWidthFor`, `toFilterGroup`,
`deriveFieldOptions`, `isImageLikeField`, `isGeoLikeField`,
`pickPreferredField`, the three `*_PREFERRED` lists, plus their types.
The roots still export every one of these names, unchanged. Both
`sideEffects` arrays name the new entry form (`./src/core.ts`,
`./dist/core.js`), as `check:side-effects-array` requires of every
entry; its derived walk finds no registering module behind either.
**The shell takes its helpers from `/core`.** Eleven importers moved:
`MetadataProvider`, `ActionParamDialog`, `ObjectFormDesigner`,
`editFormLockedByState`, `SchemaForm`, the console's `FormPage`,
`AppContent`, `objectViewRecordNavigation`, `userFilterUrlState`,
`recordDrawerStack`, `CreateViewDialog`.
**Forms drawn outside a route load on first draw.**
`views/lazyFormSurfaces.tsx` wraps `ModalForm` and `ObjectForm` in
`lazy()` + `Suspense`. `AppContent` (the global record form),
`useActionModal` (the action form) and `ScreenView` (a flow's
object-form screen) draw through it.
**The console registers the two packages' tags as lazy stubs.**
`register-plugins.ts` drops its eager `import '@object-ui/plugin-form'`
/ `'@object-ui/plugin-view'` and registers `object-form`,
`embeddable-form`, `object-master-detail-form`, `view:form`,
`record:line_items`, `object-view`, `view:simple`, `view-switcher`,
`filter-ui`, `sort-ui` with `registerLazy`, each with the namespace,
`skipFallback` and category its real registration declares.
`check:sdui-registration-pins` confirms every promised registration is
still in the built console.
**Bundling.** `apps/console/vite.config.ts` adds `plugin-form-core` and
`plugin-view-core` groups at priority 71 with
`includeDependenciesRecursively: false`, so the core modules do not land
in (and drag in) the priority-70 package chunks. `ui/vitest.config.mts`
aliases both `/core` subpaths to source, ahead of the bare package
aliases.
## Why
Card #33581 item 1. Measured with #33677's method: a production build of
the console, `dist/eager-closure.json`, gzip of the closure and of the
five watched chunks (node `zlib.gzipSync`, the report's own level).
| | main `86350e12` | this head |
|:--|--:|--:|
| eager closure (100 chunks) | 1,961,037 B | 1,909,225 B (−51,812) |
| `plugin-grid` | 160,176 eager | 160,190 eager |
| `plugin-form` | 44,205 eager | 39,961 lazy |
| `plugin-view` | 16,051 eager | 19,776 lazy |
| `plugins-views` | lazy | 40,255 lazy |
| `RecordDetailView` | lazy | 23,139 lazy |
| `plugin-form-core` (new) | — | 6,438 eager |
| `plugin-view-core` (new) | — | 1,793 eager |
`check:eager-closure` passes on this head.
## Tests
- **New pin** `app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts`
(3 tests). It reads the export names from the `/core` subpaths
themselves, scans every non-test source under `app-shell/src` and
`apps/console/src` (floors: >500 files, ≥10 `/core` importers), and
fails when (a) any of them imports a `/core` name from a package entry,
or (b) any of ten always-eager modules imports either entry by value, a
bare import included.
- **Ablation** (`scripts/ablation-replace.mjs`, restore proved by blob
== HEAD and an empty `git diff HEAD`):
- `MetadataProvider.tsx`: `resolveInlineMode` from
`'@object-ui/plugin-form'` → (a) and (b) both red, naming the file and
the name.
- `register-plugins.ts`: `import '@object-ui/plugin-detail'` → `import
'@object-ui/plugin-view'` → (b) red: `bare import from
'@object-ui/plugin-view'`.
- **Forced test edits** (each read a form or view registration through
the old eager graph):
- `apps/console/src/__tests__/masterDetailFormTypeManifest.test.ts`,
`masterDetailFormI18nLabelManifest.test.ts`,
`objectFormI18nLabelManifest.test.ts`,
`registry-inputs-spec-parity.test.ts`: `import '@object-ui/plugin-form'`
beside `../register-plugins`, because a lazy stub carries no `inputs`
and these read the manifest from `inputs` (the plugin-list precedent
from PR 1).
- `apps/console/src/__tests__/record-block-record-reach.test.tsx`: the
same import; it renders `record:line_items` synchronously.
- `apps/console/src/__tests__/public-contract.test.ts`: the same import;
the reverse direction reads `record:line_items`'s `inputs`.
`EXPECTED_LAZY` is unchanged.
-
`app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx`:
`import '@object-ui/plugin-grid'`. The related list renders through the
registered `object-grid`; this page reached it only through
plugin-view's entry (`ObjectView` imports plugin-grid). The console
registers it in `register-plugins.ts`.
- `app-shell/src/views/__tests__/FlowRunner.suspense.test.tsx`: the
mocked `ObjectForm` was itself a `lazy()`; ScreenView now takes
`ObjectForm` as the resolved value of its own `lazy()`, and React
refuses a lazy that resolves to a lazy. The mock is now a component that
renders an inner lazy body (still suspending on `formLoaded`), and the
mocked package is loaded once before `FlowRunner` so its cold load does
not eat `waitFor`'s budget.
- `app-shell/src/views/metadata-admin/previews/ScreenPreview.test.tsx`:
the two object-form tests `await screen.findByTestId('object-form')`
instead of a synchronous `getByTestId`.
- `ui/scripts/__tests__/side-effects-declaration-consistency.test.ts`:
its phantom direction ("every declared source entry has a load-time side
effect") contradicted `check-side-effects-array.mjs` and its own
coverage direction, which both require every entry form in the array. A
side-effect-free secondary entry (`src/core.ts`) could satisfy one only
by failing the other. The phantom direction now skips secondary entry
forms (exports subpaths other than the barrel) and still judges every
barrel; a new anti-vacuity line pins that the exemption reaches the two
`src/core.ts` and no `src/index.*`. Red before the edit (first gate
run), green after.
- `ui/scripts/__tests__/check-side-effects-array.test.ts`: the
population pin "every package walks from exactly one root" now names the
multi-entry population exactly: plugin-form and plugin-view, each
`['src/core.ts', 'src/index.tsx']`. The gate walks both roots and finds
the same single registrar as before.
## Acceptance notes
- **Item 2 (plugin-detail's eleven reach-ins) is not in this PR**, so it
reads `Part of`. `queueClaim.ts`, `recordFieldAccess.tsx` and
`useRecordEditable.ts` keep module-level caches with
`subscribeDataChanges` subscriptions and sit in plugin-detail's
`sideEffects` array. The shell seeds those caches
(`seedQueueClaimDecision`, `seedRecordFieldAccess`,
`seedRecordVerdict`). A `/core` built as a separate `dist/core.js`
bundle, as here and in plugin-chatbot, would carry a second copy of each
cache in the published package, so a seed written through core would
never reach the hooks the root entry reads. Routing them needs a
different published build shape (ES multi-entry with shared chunks, plus
`sideEffects` globs), which is a package-shape choice for the seat. Item
2 would also need lazy stubs for plugin-grid's and plugin-detail's tags
and a lazy `DevRowActions` (imported statically by `App.tsx`); only then
does plugin-grid (160 KB) leave the first load. The detail-core closure
measured at about 20 modules and contains no plugin-grid module.
- **`ModalForm` is not in `plugin-form/core`.** The card listed it with
the helpers, but its closure is most of the form package, so `/core`
would stop being small. The shell loads it from the entry through
`lazy()` instead (`lazyFormSurfaces.tsx`).
- **Changeset is `patch`, not `minor`.** `Metadata-protocol: none` maps
to `patch` under AGENTS.md's Post-Task Checklist step 3, and
`check-changeset-no-major` refuses `minor` with `none`.
- **plugin-form's `/core` duplicates three warning-dedupe sets**
(`reported`, `warnedHeadinglessCollapse`,
`reportedCurrencyColumnScales`) in the published package. The worst case
is a dev warning printed once more. No state the UI reads is duplicated.
In the console, Vite resolves both to one source module, so nothing is
duplicated there.
- **The FlowRunner suspension pin is now also covered by ScreenView's
own boundary.** `LazyObjectForm` carries its own `Suspense`, so a form
screen body's suspension stops inside the dialog even without
FlowRunner's. The pin still proves the route-level fallback never shows.
- **File surface breach: `ui/scripts/__tests__/**`** (two forced edits
above). The card's surface did not name the sideEffects gates' tests,
and the two checks could not both pass on any `/core` subpath of an
array package. The alternative was `sideEffects: true` for both packages
(the plugin-chatbot shape), which gives up tree-shaking for every
consumer of the two packages; I chose the narrow reconciliation. The
seat can ask for the other.
- Surface outside the card's literal list, inside its "importers"
clause: `apps/console/vite.config.ts` (chunk groups),
`ui/vitest.config.mts` (aliases). Untouched per the claim's serial
limits: plugin-view `ObjectView.tsx`, plugin-grid `ObjectGrid` and
`src/index.tsx`.
## Verification
- Type-check: plugin-form, plugin-view, app-shell, console
(`type-check`, including `tsconfig.test.json`) all exit 0.
- Affected suites: 462 files on the first pass; the 9 that went red are
the forced edits above, and they pass after the edits.
- `pnpm --dir ui check:eager-closure`, `check:side-effects-array`,
`check:sdui-registration-pins`, `check:new-line-citations` exit 0.
`eslint` on the changed files: 0 errors.
- `dispatch-gates.mjs --commands` (59 commands) run and reconciled with
`--ran`: `59 derived famil(ies) accounted for — 58 run, 1 NOT-MEASURED`.
The NOT-MEASURED one is `check:dual-build-cjs-loads` (exit 3,
prerequisite: unbuilt server packages; left to CI).
- First-run reds, fixed and rerun on this head: `pnpm --dir ui exec
vitest run scripts/` (the two sideEffects tests above; rerun 171 files
passed), `check:dts-closure` (the console's `plugin.d.ts` was absent
because the measurement build ran `vite build` only; after
`build:plugin`, 228/228 present).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 44fc2fc commit 571cf90
36 files changed
Lines changed: 550 additions & 34 deletions
File tree
- .changeset
- ui
- apps/console
- src
- __tests__
- components
- packages
- app-shell/src
- __tests__
- console
- hooks
- providers
- utils
- views
- __tests__
- metadata-admin
- previews
- studio-design
- plugin-form
- src
- plugin-view
- 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
267 | 272 | | |
268 | 273 | | |
269 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
| |||
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
62 | 95 | | |
63 | 96 | | |
64 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| 630 | + | |
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| |||
661 | 662 | | |
662 | 663 | | |
663 | 664 | | |
| 665 | + | |
664 | 666 | | |
665 | 667 | | |
666 | 668 | | |
| |||
1523 | 1525 | | |
1524 | 1526 | | |
1525 | 1527 | | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
1526 | 1552 | | |
1527 | 1553 | | |
1528 | 1554 | | |
| |||
0 commit comments