Skip to content

Commit 10d582f

Browse files
committed
test(ui): pin the detail /core subpath and the grid-free eager modules (wip)
Claude-Session: https://claude.ai/code/session_01FEkQ5kt9AD1TPLy7Y9oa9D Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5ca0636 commit 10d582f

4 files changed

Lines changed: 44 additions & 9 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/console': patch
5+
---
6+
7+
perf(console): the first load stops downloading the grid and detail packages; `@object-ui/plugin-detail/core` publishes the detail helpers without registering anything
8+
9+
Clause-②: yes (widening) — one new published `exports` subpath, `@object-ui/plugin-detail/core`, joins what the package accepts; nothing is removed or renamed, and the package root exports the same names as before
10+
Metadata-protocol: none
11+
12+
`@object-ui/plugin-detail` registers its detail and record-page renderers with `ComponentRegistry` when its root entry is evaluated, and the root reaches every detail surface (and, in the console's build, the grid it draws with). A host that imported one pure helper from the root therefore kept the whole package. The package now publishes a `/core` subpath that registers nothing: `isRefusedFeedRead`, `relatedListEntryNames`, `RELATED_ARRANGEMENT_RECORD_VERSION`, `relatedArrangementFromRecord`, `relatedArrangementToRecord`, `deriveFieldGroupDetailSections`, `deriveHighlightFields`, `resolveDetailSections`, `isWideFieldType`, `prefetchRelatedCounts`, `relatedCountTargetsIn`, `COMPACT_RELATED_ROWS`, `normalizeRelatedListSort`, `seedQueueClaimDecision`, `seedRecordFieldAccess`, `seedRecordVerdict`, and the type `RelatedArrangement`.
13+
14+
The same names stay exported from the package root, unchanged; nothing to migrate. The subpath ships ESM only (`import`), as the other `/core` subpaths do. The package's ESM build now emits one file per source module (`dist/index.js`, `dist/core.js` and the modules they import), so the record-page caches a `/core` seed writes are the ones the root's hooks read; the UMD build (`dist/index.umd.cjs`) is unchanged.
15+
16+
The console (`@object-ui/console`, and the shell it draws, `@object-ui/app-shell`) takes these helpers from the subpath, draws the record pointer card's key fields and the approval decision's child tables through `lazy()`, loads the dev-only row-actions page lazily, and registers the tags the grid and detail packages register (`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`) as lazy stubs with the namespaces those registrations declare. Neither package is downloaded on the first load any more; the list and record routes load them with their own route chunks, and any other surface loads them, and registers once, the first time it draws a grid or a detail block. What every page draws is unchanged.

‎ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
*/
88

99
/**
10-
* The console shell takes the form and view helpers from the side-effect-free
11-
* `/core` subpaths, never from the package entries (objectstack#33581).
10+
* The console shell takes the form, view and detail helpers from the
11+
* side-effect-free `/core` subpaths, never from the package entries
12+
* (objectstack#33581).
1213
*
13-
* `@object-ui/plugin-form` and `@object-ui/plugin-view` register their
14+
* `@object-ui/plugin-form`, `@object-ui/plugin-view` and
15+
* `@object-ui/plugin-detail` (which reaches `@object-ui/plugin-grid`) register their
1416
* renderers when their entry is evaluated, and each entry reaches every surface
1517
* of its package. A named import of one pure helper from an entry, in any
1618
* module the first load reaches, puts the whole package back into every first
@@ -21,9 +23,10 @@
2123
* - no shell or console source imports, from an entry, a value name its
2224
* `/core` subpath exports (the names are read from the subpath itself, so a
2325
* helper added there is covered the day it is added);
24-
* - the always-eager shell modules that draw a form or a view import nothing
25-
* from either entry by value: their components load through `lazy()`
26-
* (`views/lazyFormSurfaces.tsx`) or through the console's lazy stubs.
26+
* - the always-eager shell modules that draw a form, a view or a detail
27+
* component import nothing from those entries (nor from the grid's) by
28+
* value: their components load through `lazy()` (`views/lazyFormSurfaces.tsx`,
29+
* `views/lazyDetailSurfaces.tsx`) or through the console's lazy stubs.
2730
*
2831
* ⚠ A SOURCE SCAN: it reads import declarations, not the bundle. The built
2932
* graph is the console's `dist/eager-closure.json`; this file keeps the edges
@@ -104,7 +107,7 @@ function entryImports(file: string): EntryImport[] {
104107
const FILES = [...sourceFiles(SHELL_SRC), ...sourceFiles(CONSOLE_SRC)];
105108
const rel = (file: string) => path.relative(path.resolve(here, '../../../..'), file).split(path.sep).join('/');
106109

107-
describe('the form and view helpers come from the /core subpaths (objectstack#33581)', () => {
110+
describe('the form, view and detail helpers come from the /core subpaths (objectstack#33581)', () => {
108111
it('reads real subpaths and a real tree (floors)', () => {
109112
// The helpers the console shell measured on: each subpath must still carry them.
110113
for (const name of ['filterSystemFields', 'isAutoGeneratedFieldType', 'useInitialFieldFocus', 'resolveInlineMode']) {
@@ -113,10 +116,15 @@ describe('the form and view helpers come from the /core subpaths (objectstack#33
113116
for (const name of ['deriveRecordSurface', 'deriveRecordFlowSurface', 'overlayWidthFor', 'toFilterGroup']) {
114117
expect(ENTRIES['@object-ui/plugin-view'].has(name), name).toBe(true);
115118
}
119+
for (const name of ['isRefusedFeedRead', 'relatedListEntryNames', 'seedRecordVerdict', 'relatedCountTargetsIn']) {
120+
expect(ENTRIES['@object-ui/plugin-detail'].has(name), name).toBe(true);
121+
}
116122
expect(FILES.length).toBeGreaterThan(500);
117123
// The scan must see the subpath imports it protects, or it is reading nothing.
118124
const coreImporters = FILES.filter((f) => /from\s*['"]@object-ui\/plugin-(form|view)\/core['"]/.test(readFileSync(f, 'utf8')));
119125
expect(coreImporters.length).toBeGreaterThanOrEqual(10);
126+
const detailCoreImporters = FILES.filter((f) => /from\s*['"]@object-ui\/plugin-detail\/core['"]/.test(readFileSync(f, 'utf8')));
127+
expect(detailCoreImporters.length).toBeGreaterThanOrEqual(9);
120128
});
121129

122130
it('no shell or console source imports a /core helper from a package entry', () => {
@@ -131,7 +139,7 @@ describe('the form and view helpers come from the /core subpaths (objectstack#33
131139
expect(offenders).toEqual([]);
132140
});
133141

134-
it('the always-eager modules that draw a form or a view import neither entry by value', () => {
142+
it('the always-eager modules that draw a form, a view or a detail component import no entry by value', () => {
135143
const EAGER = [
136144
'packages/app-shell/src/console/AppContent.tsx',
137145
'packages/app-shell/src/hooks/useActionModal.tsx',
@@ -143,6 +151,15 @@ describe('the form and view helpers come from the /core subpaths (objectstack#33
143151
'packages/app-shell/src/views/userFilterUrlState.ts',
144152
'apps/console/src/components/FormPage.tsx',
145153
'apps/console/src/register-plugins.ts',
154+
'apps/console/src/App.tsx',
155+
'packages/app-shell/src/hooks/sharedUserFeeds.ts',
156+
'packages/app-shell/src/utils/deriveRelatedLists.ts',
157+
'packages/app-shell/src/utils/workspacePreference.ts',
158+
'packages/app-shell/src/views/recordPagePayload.ts',
159+
'packages/app-shell/src/views/recordDetailSections.ts',
160+
'packages/app-shell/src/views/lazyDetailSurfaces.tsx',
161+
'packages/app-shell/src/views/record-preview/RecordPreviewCard.tsx',
162+
'packages/app-shell/src/views/approval-decision/SubmittedRecord.tsx',
146163
];
147164
const offenders: string[] = [];
148165
for (const r of EAGER) {

‎ui/scripts/__tests__/check-side-effects-array.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ describe('the real workspace — the population this widening was measured again
795795
const kinds = results.flatMap((r) => r.entryForms.map((e) => e.kind));
796796
expect(kinds).toContain('asset'); // @object-ui/app-shell's `./styles.css`
797797
expect(results.flatMap((r) => r.entryForms.flatMap((e) => e.alternateFormats)).length).toBeGreaterThan(0);
798-
// ...and the genuine multi-entry population is exactly the two `/core`
798+
// ...and the genuine multi-entry population is exactly the three `/core`
799799
// subpaths objectstack#33581 published: side-effect-free secondary entry
800800
// points, walked as roots of their own (and finding no registrar, which is
801801
// their point). Every other package still walks from one root. A package
@@ -804,6 +804,7 @@ describe('the real workspace — the population this widening was measured again
804804
results.filter((r) => r.entryPoints.length > 1).map((r) => [r.name, r.entryPoints]),
805805
);
806806
expect(multi).toEqual({
807+
'@object-ui/plugin-detail': ['src/core.ts', 'src/index.tsx'],
807808
'@object-ui/plugin-form': ['src/core.ts', 'src/index.tsx'],
808809
'@object-ui/plugin-view': ['src/core.ts', 'src/index.tsx'],
809810
});

‎ui/scripts/__tests__/side-effects-declaration-consistency.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ describe('`sideEffects` declarations match load-time behaviour (objectui#3943)',
14511451
);
14521452
expect(exempt).toContain('@object-ui/plugin-form/src/core.ts');
14531453
expect(exempt).toContain('@object-ui/plugin-view/src/core.ts');
1454+
expect(exempt).toContain('@object-ui/plugin-detail/src/core.ts');
14541455
expect(exempt.filter((e) => /\/src\/index\.[a-z]+$/.test(e))).toEqual([]);
14551456
});
14561457

0 commit comments

Comments
 (0)