From 29d1658bd4cd083525e6e2f1bbe15678e4f95012 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 22:26:30 +0000 Subject: [PATCH 1/7] perf(console): plugin-form and plugin-view helpers come from side-effect-free /core subpaths The console shell imports the pure helpers from @object-ui/plugin-form/core and @object-ui/plugin-view/core, draws ModalForm and the flow screen's ObjectForm behind lazy(), and registers the two packages' tags as lazy stubs, so neither entry is part of the first load. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- ui/apps/console/src/components/FormPage.tsx | 2 +- ui/apps/console/src/register-plugins.ts | 39 ++++++++++++++-- ui/apps/console/vite.config.ts | 26 +++++++++++ .../app-shell/src/console/AppContent.tsx | 6 +-- .../app-shell/src/hooks/useActionModal.tsx | 4 +- .../src/providers/MetadataProvider.tsx | 2 +- .../src/utils/editFormLockedByState.ts | 2 +- .../app-shell/src/views/ActionParamDialog.tsx | 2 +- .../app-shell/src/views/CreateViewDialog.tsx | 2 +- .../app-shell/src/views/ScreenView.tsx | 4 +- .../app-shell/src/views/lazyFormSurfaces.tsx | 45 +++++++++++++++++++ .../src/views/metadata-admin/SchemaForm.tsx | 2 +- .../src/views/objectViewRecordNavigation.ts | 2 +- .../app-shell/src/views/recordDrawerStack.tsx | 2 +- .../studio-design/ObjectFormDesigner.tsx | 2 +- .../app-shell/src/views/userFilterUrlState.ts | 2 +- ui/packages/plugin-form/package.json | 6 ++- ui/packages/plugin-form/src/core.ts | 37 +++++++++++++++ ui/packages/plugin-form/vite.core.config.ts | 33 ++++++++++++++ ui/packages/plugin-view/package.json | 6 ++- ui/packages/plugin-view/src/core.ts | 37 +++++++++++++++ ui/packages/plugin-view/vite.core.config.ts | 33 ++++++++++++++ ui/vitest.config.mts | 2 + 23 files changed, 276 insertions(+), 22 deletions(-) create mode 100644 ui/packages/app-shell/src/views/lazyFormSurfaces.tsx create mode 100644 ui/packages/plugin-form/src/core.ts create mode 100644 ui/packages/plugin-form/vite.core.config.ts create mode 100644 ui/packages/plugin-view/src/core.ts create mode 100644 ui/packages/plugin-view/vite.core.config.ts diff --git a/ui/apps/console/src/components/FormPage.tsx b/ui/apps/console/src/components/FormPage.tsx index 830a344674f..16940fe4e32 100644 --- a/ui/apps/console/src/components/FormPage.tsx +++ b/ui/apps/console/src/components/FormPage.tsx @@ -136,7 +136,7 @@ import { omitServerResolvedDefaults, optionListDefault, resolveSectionGroupReferences, -} from '@object-ui/plugin-form'; +} from '@object-ui/plugin-form/core'; // ADR-0059's published door for a host that renders field widgets OUTSIDE the // form renderer: `resolveFormWidgetType` + `getLazyFieldWidget` hand back the // very component `@object-ui/fields` registers for the form, so a host built on diff --git a/ui/apps/console/src/register-plugins.ts b/ui/apps/console/src/register-plugins.ts index 9e32b27df4b..292ebd0d0fc 100644 --- a/ui/apps/console/src/register-plugins.ts +++ b/ui/apps/console/src/register-plugins.ts @@ -26,11 +26,9 @@ import { ComponentRegistry } from '@object-ui/core'; // Eager imports — core views the console shell itself imports by name today -// (the shell's own helpers and record surfaces reach these four packages' +// (the shell's own helpers and record surfaces reach these two packages' // entries), so a lazy stub here would move nothing out of the first load. import '@object-ui/plugin-grid'; -import '@object-ui/plugin-form'; -import '@object-ui/plugin-view'; import '@object-ui/plugin-detail'; // Lazy plugins — registered as deferred loaders. The first time the @@ -59,6 +57,41 @@ ComponentRegistry.registerLazy('object-gallery', () => import('@object-ui/plugin category: 'view', }); +// The form and the object view: the shell takes their pure helpers from the +// side-effect-free `/core` subpaths and draws their components behind +// `lazy()`, so nothing on the first load imports either entry. Each tag the +// entry registers is a stub with the namespace, `skipFallback` and category +// that registration declares; the first schema naming one loads the package, +// whose own registrations then replace every stub of it, once. +for (const variant of ['object-form', 'embeddable-form', 'object-master-detail-form']) { + ComponentRegistry.registerLazy(variant, () => import('@object-ui/plugin-form'), { + namespace: 'plugin-form', + category: 'plugin', + }); +} +ComponentRegistry.registerLazy('form', () => import('@object-ui/plugin-form'), { + namespace: 'view', + skipFallback: true, + category: 'view', +}); +ComponentRegistry.registerLazy('line_items', () => import('@object-ui/plugin-form'), { + namespace: 'record', + skipFallback: true, + category: 'record', +}); +for (const variant of ['object-view', 'view:simple']) { + ComponentRegistry.registerLazy(variant, () => import('@object-ui/plugin-view'), { + namespace: 'plugin-view', + category: 'view', + }); +} +for (const variant of ['view-switcher', 'filter-ui', 'sort-ui']) { + ComponentRegistry.registerLazy(variant, () => import('@object-ui/plugin-view'), { + namespace: 'view', + category: 'view', + }); +} + ComponentRegistry.registerLazy('object-map', () => import('@object-ui/plugin-map'), { namespace: 'plugin-map', category: 'view', diff --git a/ui/apps/console/vite.config.ts b/ui/apps/console/vite.config.ts index 0498dd10ff5..42c624ba3e2 100644 --- a/ui/apps/console/vite.config.ts +++ b/ui/apps/console/vite.config.ts @@ -627,6 +627,7 @@ const workspaceAliases: Record = { '@object-ui/layout': path.resolve(import.meta.dirname, '../../packages/layout/src'), '@object-ui/plugin-dashboard': path.resolve(import.meta.dirname, '../../packages/plugin-dashboard/src'), '@object-ui/plugin-report': path.resolve(import.meta.dirname, '../../packages/plugin-report/src'), + '@object-ui/plugin-form/core': path.resolve(import.meta.dirname, '../../packages/plugin-form/src/core.ts'), '@object-ui/plugin-form': path.resolve(import.meta.dirname, '../../packages/plugin-form/src'), '@object-ui/plugin-grid': path.resolve(import.meta.dirname, '../../packages/plugin-grid/src'), '@object-ui/react': path.resolve(import.meta.dirname, '../../packages/react/src'), @@ -661,6 +662,7 @@ const workspaceAliases: Record = { '@object-ui/plugin-markdown': path.resolve(import.meta.dirname, '../../packages/plugin-markdown/src'), '@object-ui/plugin-timeline': path.resolve(import.meta.dirname, '../../packages/plugin-timeline/src'), '@object-ui/plugin-tree': path.resolve(import.meta.dirname, '../../packages/plugin-tree/src'), + '@object-ui/plugin-view/core': path.resolve(import.meta.dirname, '../../packages/plugin-view/src/core.ts'), '@object-ui/plugin-view': path.resolve(import.meta.dirname, '../../packages/plugin-view/src'), '@object-ui/plugin-designer': path.resolve(import.meta.dirname, '../../packages/plugin-designer/src'), }; @@ -1523,6 +1525,30 @@ export default defineConfig({ { name: 'plugin-calendar', test: /[\\/]packages[\\/]plugin-calendar[\\/]/, priority: 70 }, { name: 'plugin-kanban', test: /[\\/]packages[\\/]plugin-kanban[\\/]/, priority: 70 }, // + // ## The form and view helpers stay out of their plugin chunks + // + // The console shell is eager and imports pure helpers through + // `@object-ui/plugin-form/core` and `@object-ui/plugin-view/core`. + // Left to the `plugin-form` / `plugin-view` groups above, those + // modules would be co-tenants of the renderers and pull each whole + // chunk back into every first load, the mechanism the chatbot group + // below names. Each group takes exactly the modules its `core.ts` + // reaches inside its package, for the reason `types-zod` above gives + // for `includeDependenciesRecursively: false`. ⛔ A module added to a + // `core.ts` closure belongs in its list. + { + name: 'plugin-form-core', + test: /[\\/]packages[\\/]plugin-form[\\/]src[\\/](core|autoLayout|sanitize|deriveMasterDetail|schemaDefaults|sectionGroups|fieldGroups|initialFieldFocus)\.tsx?$/, + priority: 71, + includeDependenciesRecursively: false, + }, + { + name: 'plugin-view-core', + test: /[\\/]packages[\\/]plugin-view[\\/]src[\\/](core|recordSurface|config[\\/]view-config-utils)\.tsx?$/, + priority: 71, + includeDependenciesRecursively: false, + }, + // // ## The chatbot's side-effect-free half stays out of its chunk (objectui#13410) // // The console shell is eager and imports the agent catalog hook and a diff --git a/ui/packages/app-shell/src/console/AppContent.tsx b/ui/packages/app-shell/src/console/AppContent.tsx index 5aad87a72da..a7f2bae5226 100644 --- a/ui/packages/app-shell/src/console/AppContent.tsx +++ b/ui/packages/app-shell/src/console/AppContent.tsx @@ -11,7 +11,7 @@ import { Routes, Route, Navigate, matchRoutes, useNavigate, useLocation, useParams, useSearchParams } from 'react-router-dom'; import { useState, useEffect, useLayoutEffect, useCallback, useRef, lazy, Suspense, useMemo, createElement, type ComponentType, type ReactNode } from 'react'; import { useAssistant } from '../assistant/assistantBus.js'; -import { ModalForm } from '@object-ui/plugin-form'; +import { LazyModalForm } from '../views/lazyFormSurfaces.js'; import { Empty, EmptyTitle, EmptyDescription, Button, DataErrorState } from '@object-ui/components'; import { toast } from 'sonner'; import { useActionRunner, useGlobalUndo, useMutationInvalidationBridge, notifyDataChanged, FilterScopeProvider, resolveApprovalLock, claimAnswerWarnings, toastRecordSave, type AnswerWarningClaim, type AnsweredLoadFailure, type RecordSaveFeedback } from '@object-ui/react'; @@ -37,7 +37,7 @@ import { useHomePath } from '../hooks/useHomePath.js'; import { readItemPreferLocal, useReadItemsByName } from '../hooks/useObjectPresence.js'; import { useLauncherApps } from '../hooks/useLauncherApps.js'; import { resolveRecordFormTarget, resolveRecordFormModalLayout, resolveFormViewChrome, selectRecordFormView, resolveNavigateCreateUrl, resolveNavigateEditUrl, resolvePostCreateTarget, recordFormCreateValues, readRecordFormCreateValues, RECORD_FORM_CREATE_VALUES_STATE } from '../utils/recordFormNavigation.js'; -import { deriveRecordSurface, deriveRecordFlowSurface } from '@object-ui/plugin-view'; +import { deriveRecordSurface, deriveRecordFlowSurface } from '@object-ui/plugin-view/core'; import { isPhoneViewportNow } from '../hooks/usePhoneViewport.js'; import { servedObjectLabel, servedObjectPluralLabel } from '../hooks/servedObjectLabel.js'; import { RECORD_DRAWER_PARAM, RECORD_FORM_PARAM, RECORD_FORM_OBJECT_PARAM, RECORD_FORM_LINK_PARAM } from '../urlParams.js'; @@ -1698,7 +1698,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps = {formObjectDef && ( - {dataSource ? ( - import('@object-ui/plugin-form').then((m) => ({ default: m.ModalForm }))); +const ObjectFormChunk = lazy(() => import('@object-ui/plugin-form').then((m) => ({ default: m.ObjectForm }))); + +/** `ModalForm`, loaded on first draw. Nothing shows until the form chunk is in. */ +export function LazyModalForm(props: ComponentProps) { + return ( + + + + ); +} + +/** `ObjectForm`, loaded on first draw. Nothing shows until the form chunk is in. */ +export function LazyObjectForm(props: ComponentProps) { + return ( + + + + ); +} diff --git a/ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx b/ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx index edfccccb225..98f6e3c0cd3 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx @@ -56,7 +56,7 @@ import { CollapsibleContent, } from '@object-ui/components'; import { usePredicateScope } from '@object-ui/react'; -import { resolveSectionGroupReferences } from '@object-ui/plugin-form'; +import { resolveSectionGroupReferences } from '@object-ui/plugin-form/core'; import { evaluatePredicate, buildPredicateCtx, visibleOptions } from './predicate.js'; import type { FormFieldSpec, FormSectionSpec, FormViewSpec, VisibilityPredicate } from './form-spec.js'; import { diff --git a/ui/packages/app-shell/src/views/objectViewRecordNavigation.ts b/ui/packages/app-shell/src/views/objectViewRecordNavigation.ts index af43c25b071..bb538218434 100644 --- a/ui/packages/app-shell/src/views/objectViewRecordNavigation.ts +++ b/ui/packages/app-shell/src/views/objectViewRecordNavigation.ts @@ -34,7 +34,7 @@ import { useMemo, useCallback, useEffect, useRef, useState } from 'react'; import type { NavigateFunction, Location, SetURLSearchParams } from 'react-router-dom'; -import { deriveRecordSurface, overlayWidthFor } from '@object-ui/plugin-view'; +import { deriveRecordSurface, overlayWidthFor } from '@object-ui/plugin-view/core'; import { useNavigationOverlay } from '@object-ui/react'; import { usePermissions } from '@object-ui/permissions'; import type { ViewNavigationConfig } from '@object-ui/types'; diff --git a/ui/packages/app-shell/src/views/recordDrawerStack.tsx b/ui/packages/app-shell/src/views/recordDrawerStack.tsx index 053c2167b48..54857658867 100644 --- a/ui/packages/app-shell/src/views/recordDrawerStack.tsx +++ b/ui/packages/app-shell/src/views/recordDrawerStack.tsx @@ -64,7 +64,7 @@ import { type NavigationOverlayMode, type RecordTopBarStepper, } from '@object-ui/components'; -import { overlayWidthFor } from '@object-ui/plugin-view'; +import { overlayWidthFor } from '@object-ui/plugin-view/core'; import type { FieldContainerLike } from '@object-ui/core'; import { useObjectLabel, useObjectTranslation } from '@object-ui/i18n'; import { servedObjectLabel, servedObjectPluralLabel } from '../hooks/servedObjectLabel.js'; diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectFormDesigner.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectFormDesigner.tsx index 01aa9eb0b6b..7a20429d957 100644 --- a/ui/packages/app-shell/src/views/studio-design/ObjectFormDesigner.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ObjectFormDesigner.tsx @@ -46,7 +46,7 @@ import { SortableContext, verticalListSortingStrategy, useSortable, arrayMove } import { CSS } from '@dnd-kit/utilities'; import { GripVertical, Plus, Trash2, ChevronUp, ChevronDown, ChevronsUpDown, PanelTop, Settings2 } from 'lucide-react'; import { cn } from '@object-ui/components'; -import { inferColumns, containerGridColsFor, isWideFieldType } from '@object-ui/plugin-form'; +import { inferColumns, containerGridColsFor, isWideFieldType } from '@object-ui/plugin-form/core'; import { toFormFieldType } from './formFieldType.js'; import { resolveBooleanControl } from '@object-ui/fields'; import { diff --git a/ui/packages/app-shell/src/views/userFilterUrlState.ts b/ui/packages/app-shell/src/views/userFilterUrlState.ts index 0f071bc5f25..453d41daef3 100644 --- a/ui/packages/app-shell/src/views/userFilterUrlState.ts +++ b/ui/packages/app-shell/src/views/userFilterUrlState.ts @@ -60,7 +60,7 @@ import { GroupingConfigSchema, ListViewSchema, ViewFilterRuleSchema } from '@objectstack/spec/ui'; import type { GroupingConfig, ViewFilterRule } from '@objectstack/spec/ui'; import type { FilterBuilderRowGroup } from '@object-ui/components'; -import { toFilterGroup } from '@object-ui/plugin-view'; +import { toFilterGroup } from '@object-ui/plugin-view/core'; import { foldFilterGroupToSpecRules } from './viewFilterFold.js'; const PREFIX = 'uf_'; diff --git a/ui/packages/plugin-form/package.json b/ui/packages/plugin-form/package.json index 83f7a5f51dc..d59eb68b9df 100644 --- a/ui/packages/plugin-form/package.json +++ b/ui/packages/plugin-form/package.json @@ -17,10 +17,14 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.umd.cjs" + }, + "./core": { + "types": "./dist/core.d.ts", + "import": "./dist/core.js" } }, "scripts": { - "build": "vite build", + "build": "vite build && vite build --config vite.core.config.ts", "test": "vitest run --root ../.. packages/plugin-form/", "type-check": "tsc --noEmit && tsc -p tsconfig.test.json", "lint": "eslint ." diff --git a/ui/packages/plugin-form/src/core.ts b/ui/packages/plugin-form/src/core.ts new file mode 100644 index 00000000000..1b3ccbde4be --- /dev/null +++ b/ui/packages/plugin-form/src/core.ts @@ -0,0 +1,37 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * `@object-ui/plugin-form/core` — the side-effect-free half of this package. + * + * The package root registers the form renderers with `ComponentRegistry` when + * it is evaluated and statically reaches every form surface, so a host that + * imports one pure helper from the root keeps all of it in its own chunk. The + * console shell imports the helpers below from this subpath instead, and the + * form renderers load (and register) only when a form is drawn. + * + * ⛔ Nothing exported here may import a form component, `./index` or a module + * that registers, directly or through a neighbour: the subpath is only worth + * having while its closure stays these pure functions and one hook. The same + * names are still exported from the package root, unchanged. A module added + * to this file's closure also joins the console's `plugin-form-core` chunk + * group (`apps/console/vite.config.ts`). + */ + +export { + inferColumns, + isWideFieldType, + isAutoGeneratedFieldType, + containerGridColsFor, + filterSystemFields, +} from './autoLayout'; +export { resolveInlineMode } from './deriveMasterDetail'; +export type { InlineMode } from './deriveMasterDetail'; +export { omitServerResolvedDefaults, optionListDefault } from './schemaDefaults'; +export type { FieldDefaultsSchemaLike, OptionListFieldLike } from './schemaDefaults'; +export { resolveSectionGroupReferences } from './sectionGroups'; +export type { ResolveSectionGroupsOptions } from './sectionGroups'; +export { useInitialFieldFocus } from './initialFieldFocus'; diff --git a/ui/packages/plugin-form/vite.core.config.ts b/ui/packages/plugin-form/vite.core.config.ts new file mode 100644 index 00000000000..19451be38b3 --- /dev/null +++ b/ui/packages/plugin-form/vite.core.config.ts @@ -0,0 +1,33 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { defineConfig } from 'vite'; +import { resolve } from 'path'; + +/** + * Second build pass: `dist/core.js`, the `@object-ui/plugin-form/core` + * subpath. See `src/core.ts` for why the subpath exists. + * + * A pass of its own because the main build emits UMD, and a lib build with + * more than one entry cannot. Its typings come from the main pass, whose + * `dts` plugin already emits every `src` module, `dist/core.d.ts` included. + * ⛔ `emptyOutDir: false`: this pass runs second and must not delete them. + */ +export default defineConfig({ + build: { + emptyOutDir: false, + lib: { + entry: resolve(__dirname, 'src/core.ts'), + formats: ['es'], + fileName: () => 'core.js', + }, + rollupOptions: { + external: (id) => !/^[./]/.test(id) && !id.startsWith(__dirname), + }, + }, +}); diff --git a/ui/packages/plugin-view/package.json b/ui/packages/plugin-view/package.json index 708a9290b14..69efe58e6e4 100644 --- a/ui/packages/plugin-view/package.json +++ b/ui/packages/plugin-view/package.json @@ -17,10 +17,14 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.umd.cjs" + }, + "./core": { + "types": "./dist/core.d.ts", + "import": "./dist/core.js" } }, "scripts": { - "build": "vite build", + "build": "vite build && vite build --config vite.core.config.ts", "test": "vitest run --root ../.. packages/plugin-view/", "type-check": "tsc --noEmit && tsc -p tsconfig.test.json", "lint": "eslint ." diff --git a/ui/packages/plugin-view/src/core.ts b/ui/packages/plugin-view/src/core.ts new file mode 100644 index 00000000000..bb3734be85f --- /dev/null +++ b/ui/packages/plugin-view/src/core.ts @@ -0,0 +1,37 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * `@object-ui/plugin-view/core` — the side-effect-free half of this package. + * + * The package root registers the view renderers with `ComponentRegistry` when + * it is evaluated and statically reaches `ObjectView`, which reaches the grid + * and the form, so a host that imports one pure helper from the root keeps all + * of them in its own chunk. The console shell imports the helpers below from + * this subpath instead, and the view renderers load (and register) only when a + * view is drawn. + * + * ⛔ Nothing exported here may import a view component, `./index` or a module + * that registers, directly or through a neighbour: the subpath is only worth + * having while its closure stays these pure functions and constants. The same + * names are still exported from the package root, unchanged. A module added to + * this file's closure also joins the console's `plugin-view-core` chunk group + * (`apps/console/vite.config.ts`). + */ + +export { deriveRecordSurface, deriveRecordFlowSurface, overlayWidthFor } from './recordSurface'; +export type { RecordSurface, RecordFlowSurface } from './recordSurface'; +export { + deriveFieldOptions, + toFilterGroup, + isImageLikeField, + isGeoLikeField, + pickPreferredField, + KANBAN_GROUP_PREFERRED, + PRIMARY_DATE_PREFERRED, + END_DATE_PREFERRED, +} from './config/view-config-utils'; +export type { FieldOption } from './config/view-config-utils'; diff --git a/ui/packages/plugin-view/vite.core.config.ts b/ui/packages/plugin-view/vite.core.config.ts new file mode 100644 index 00000000000..ae70f0fd94f --- /dev/null +++ b/ui/packages/plugin-view/vite.core.config.ts @@ -0,0 +1,33 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { defineConfig } from 'vite'; +import { resolve } from 'path'; + +/** + * Second build pass: `dist/core.js`, the `@object-ui/plugin-view/core` + * subpath. See `src/core.ts` for why the subpath exists. + * + * A pass of its own because the main build emits UMD, and a lib build with + * more than one entry cannot. Its typings come from the main pass, whose + * `dts` plugin already emits every `src` module, `dist/core.d.ts` included. + * ⛔ `emptyOutDir: false`: this pass runs second and must not delete them. + */ +export default defineConfig({ + build: { + emptyOutDir: false, + lib: { + entry: resolve(__dirname, 'src/core.ts'), + formats: ['es'], + fileName: () => 'core.js', + }, + rollupOptions: { + external: (id) => !/^[./]/.test(id) && !id.startsWith(__dirname), + }, + }, +}); diff --git a/ui/vitest.config.mts b/ui/vitest.config.mts index 658bd69c0f1..20ded5433cb 100644 --- a/ui/vitest.config.mts +++ b/ui/vitest.config.mts @@ -542,11 +542,13 @@ export default defineConfig({ '@object-ui/plugin-chatbot': path.resolve(__dirname, './packages/plugin-chatbot/src'), '@object-ui/plugin-detail': path.resolve(__dirname, './packages/plugin-detail/src'), '@object-ui/plugin-editor': path.resolve(__dirname, './packages/plugin-editor/src'), + '@object-ui/plugin-form/core': path.resolve(__dirname, './packages/plugin-form/src/core.ts'), '@object-ui/plugin-form': path.resolve(__dirname, './packages/plugin-form/src'), '@object-ui/plugin-gantt': path.resolve(__dirname, './packages/plugin-gantt/src'), '@object-ui/plugin-map': path.resolve(__dirname, './packages/plugin-map/src'), '@object-ui/plugin-markdown': path.resolve(__dirname, './packages/plugin-markdown/src'), '@object-ui/plugin-timeline': path.resolve(__dirname, './packages/plugin-timeline/src'), + '@object-ui/plugin-view/core': path.resolve(__dirname, './packages/plugin-view/src/core.ts'), '@object-ui/plugin-view': path.resolve(__dirname, './packages/plugin-view/src'), '@object-ui/plugin-report': path.resolve(__dirname, './packages/plugin-report/src'), '@object-ui/plugin-designer': path.resolve(__dirname, './packages/plugin-designer/src'), From 0b9ea7bfb3485a2b46865d4eed88536170ace935 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 22:29:22 +0000 Subject: [PATCH 2/7] test(app-shell): pin the shell's form and view helpers to the /core subpaths Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- .../pluginCoreSubpaths-33581.test.ts | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts diff --git a/ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts b/ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts new file mode 100644 index 00000000000..c0ceeed3ce0 --- /dev/null +++ b/ui/packages/app-shell/src/__tests__/pluginCoreSubpaths-33581.test.ts @@ -0,0 +1,152 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * The console shell takes the form and view helpers from the side-effect-free + * `/core` subpaths, never from the package entries (objectstack#33581). + * + * `@object-ui/plugin-form` and `@object-ui/plugin-view` register their + * renderers when their entry is evaluated, and each entry reaches every surface + * of its package. A named import of one pure helper from an entry, in any + * module the first load reaches, puts the whole package back into every first + * load; nothing else says so, because the console's eager-closure budget is far + * coarser than one plugin chunk. + * + * Two pins: + * - no shell or console source imports, from an entry, a value name its + * `/core` subpath exports (the names are read from the subpath itself, so a + * helper added there is covered the day it is added); + * - the always-eager shell modules that draw a form or a view import nothing + * from either entry by value: their components load through `lazy()` + * (`views/lazyFormSurfaces.tsx`) or through the console's lazy stubs. + * + * ⚠ A SOURCE SCAN: it reads import declarations, not the bundle. The built + * graph is the console's `dist/eager-closure.json`; this file keeps the edges + * that graph was measured on from coming back one import at a time. + */ + +import { describe, it, expect } from 'vitest'; +import { readFileSync, readdirSync, statSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import * as formCore from '@object-ui/plugin-form/core'; +import * as viewCore from '@object-ui/plugin-view/core'; +// @ts-expect-error — plain-JS shared helper, intentionally untyped (`allowJs: false`) +import { maskComments } from '../../../../scripts/js-comment-mask.mjs'; + +const mask: (source: string) => string = maskComments; + +const here = path.dirname(fileURLToPath(import.meta.url)); +const SHELL_SRC = path.resolve(here, '..'); +const CONSOLE_SRC = path.resolve(here, '../../../../apps/console/src'); + +const ENTRIES = { + '@object-ui/plugin-form': new Set(Object.keys(formCore)), + '@object-ui/plugin-view': new Set(Object.keys(viewCore)), +} as const; +type Entry = keyof typeof ENTRIES; + +function sourceFiles(dir: string): string[] { + const out: string[] = []; + for (const name of readdirSync(dir)) { + const full = path.join(dir, name); + if (statSync(full).isDirectory()) { + if (name === '__tests__' || name === '__mocks__' || name === 'node_modules') continue; + out.push(...sourceFiles(full)); + } else if (/\.(ts|tsx)$/.test(name) && !/\.(test|spec)\.tsx?$/.test(name) && !name.endsWith('.d.ts')) { + out.push(full); + } + } + return out; +} + +interface EntryImport { + file: string; + entry: Entry; + /** Value names; `null` for a bare side-effect import. */ + values: string[] | null; +} + +const IMPORT_RE = /\bimport\s+(type\s+)?([\s\S]*?)\s*from\s*['"]([^'"]+)['"]|\bimport\s+['"]([^'"]+)['"]/g; + +function entryImports(file: string): EntryImport[] { + const source = mask(readFileSync(file, 'utf8')); + const found: EntryImport[] = []; + for (const m of source.matchAll(IMPORT_RE)) { + const specifier = (m[3] ?? m[4]) as string; + if (!(specifier in ENTRIES)) continue; + const entry = specifier as Entry; + if (m[4]) { found.push({ file, entry, values: null }); continue; } + if (m[1]) continue; // `import type { … }` is erased + const clause = m[2] as string; + const named = /\{([\s\S]*)\}/.exec(clause)?.[1] ?? ''; + const values = named + .split(',') + .map((s) => s.trim()) + .filter((s) => s !== '' && !s.startsWith('type ')) + .map((s) => s.split(/\s+as\s+/)[0] as string); + const defaultOrNs = clause.replace(/\{[\s\S]*\}/, '').replace(/,/g, '').trim(); + if (defaultOrNs !== '') values.push(defaultOrNs); + found.push({ file, entry, values }); + } + return found; +} + +const FILES = [...sourceFiles(SHELL_SRC), ...sourceFiles(CONSOLE_SRC)]; +const rel = (file: string) => path.relative(path.resolve(here, '../../../..'), file).split(path.sep).join('/'); + +describe('the form and view helpers come from the /core subpaths (objectstack#33581)', () => { + it('reads real subpaths and a real tree (floors)', () => { + // The helpers the console shell measured on: each subpath must still carry them. + for (const name of ['filterSystemFields', 'isAutoGeneratedFieldType', 'useInitialFieldFocus', 'resolveInlineMode']) { + expect(ENTRIES['@object-ui/plugin-form'].has(name), name).toBe(true); + } + for (const name of ['deriveRecordSurface', 'deriveRecordFlowSurface', 'overlayWidthFor', 'toFilterGroup']) { + expect(ENTRIES['@object-ui/plugin-view'].has(name), name).toBe(true); + } + expect(FILES.length).toBeGreaterThan(500); + // The scan must see the subpath imports it protects, or it is reading nothing. + const coreImporters = FILES.filter((f) => /from\s*['"]@object-ui\/plugin-(form|view)\/core['"]/.test(readFileSync(f, 'utf8'))); + expect(coreImporters.length).toBeGreaterThanOrEqual(10); + }); + + it('no shell or console source imports a /core helper from a package entry', () => { + const offenders: string[] = []; + for (const file of FILES) { + for (const { entry, values } of entryImports(file)) { + for (const name of values ?? []) { + if (ENTRIES[entry].has(name)) offenders.push(`${rel(file)}: ${name} from '${entry}' (use '${entry}/core')`); + } + } + } + expect(offenders).toEqual([]); + }); + + it('the always-eager modules that draw a form or a view import neither entry by value', () => { + const EAGER = [ + 'packages/app-shell/src/console/AppContent.tsx', + 'packages/app-shell/src/hooks/useActionModal.tsx', + 'packages/app-shell/src/views/ScreenView.tsx', + 'packages/app-shell/src/views/lazyFormSurfaces.tsx', + 'packages/app-shell/src/providers/MetadataProvider.tsx', + 'packages/app-shell/src/views/ActionParamDialog.tsx', + 'packages/app-shell/src/views/recordDrawerStack.tsx', + 'packages/app-shell/src/views/userFilterUrlState.ts', + 'apps/console/src/components/FormPage.tsx', + 'apps/console/src/register-plugins.ts', + ]; + const offenders: string[] = []; + for (const r of EAGER) { + const file = path.resolve(here, '../../../..', r); + for (const { entry, values } of entryImports(file)) { + offenders.push(`${r}: ${values === null ? 'bare import' : values.join(', ')} from '${entry}'`); + } + } + expect(offenders).toEqual([]); + }); +}); From 67445c904719924f477650e97afa92a0cdbb755b Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 22:56:22 +0000 Subject: [PATCH 3/7] test(console,app-shell): load the form and grid packages where a suite read them through the old eager graph The console registers the form tags as lazy stubs now, and the shell draws its forms through lazy(); suites that read a form block's inputs or rendered a form synchronously load the package themselves or wait for it. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- .../masterDetailFormI18nLabelManifest.test.ts | 4 ++++ .../masterDetailFormTypeManifest.test.ts | 4 ++++ .../objectFormI18nLabelManifest.test.ts | 4 ++++ .../src/__tests__/public-contract.test.ts | 5 +++++ .../record-block-record-reach.test.tsx | 4 ++++ .../registry-inputs-spec-parity.test.ts | 5 +++++ ...w.childWriteRefreshesParent-12244.test.tsx | 6 ++++++ .../__tests__/FlowRunner.suspense.test.tsx | 19 +++++++++++++++---- .../previews/ScreenPreview.test.tsx | 10 +++++++--- 9 files changed, 54 insertions(+), 7 deletions(-) diff --git a/ui/apps/console/src/__tests__/masterDetailFormI18nLabelManifest.test.ts b/ui/apps/console/src/__tests__/masterDetailFormI18nLabelManifest.test.ts index d1a27fe3efb..7558d8f87a1 100644 --- a/ui/apps/console/src/__tests__/masterDetailFormI18nLabelManifest.test.ts +++ b/ui/apps/console/src/__tests__/masterDetailFormI18nLabelManifest.test.ts @@ -29,6 +29,10 @@ import { manifestFromConfigs, validateTree } from '@objectstack/sdui-parser'; import type { Diagnostic, SchemaElement } from '@objectstack/sdui-parser'; import '@object-ui/components'; import '../register-plugins'; +// `@object-ui/plugin-form` too: the console registers its tags as lazy stubs +// since its first load stopped carrying the package (objectstack#33581), and +// a stub carries no `inputs`, which is what this manifest is read from. +import '@object-ui/plugin-form'; const manifest = manifestFromConfigs( ComponentRegistry.getPublicConfigs() as unknown as Parameters[0], diff --git a/ui/apps/console/src/__tests__/masterDetailFormTypeManifest.test.ts b/ui/apps/console/src/__tests__/masterDetailFormTypeManifest.test.ts index 78860c8d200..180cd6f673d 100644 --- a/ui/apps/console/src/__tests__/masterDetailFormTypeManifest.test.ts +++ b/ui/apps/console/src/__tests__/masterDetailFormTypeManifest.test.ts @@ -32,6 +32,10 @@ import { manifestFromConfigs, validateTree } from '@objectstack/sdui-parser'; import type { Diagnostic, SchemaElement } from '@objectstack/sdui-parser'; import '@object-ui/components'; import '../register-plugins'; +// `@object-ui/plugin-form` too: the console registers its tags as lazy stubs +// since its first load stopped carrying the package (objectstack#33581), and +// a stub carries no `inputs`, which is what this manifest is read from. +import '@object-ui/plugin-form'; const manifest = manifestFromConfigs( ComponentRegistry.getAllConfigs() as unknown as Parameters[0], diff --git a/ui/apps/console/src/__tests__/objectFormI18nLabelManifest.test.ts b/ui/apps/console/src/__tests__/objectFormI18nLabelManifest.test.ts index 17b01f74197..a492ee51995 100644 --- a/ui/apps/console/src/__tests__/objectFormI18nLabelManifest.test.ts +++ b/ui/apps/console/src/__tests__/objectFormI18nLabelManifest.test.ts @@ -29,6 +29,10 @@ import { manifestFromConfigs, validateTree } from '@objectstack/sdui-parser'; import type { Diagnostic, SchemaElement } from '@objectstack/sdui-parser'; import '@object-ui/components'; import '../register-plugins'; +// `@object-ui/plugin-form` too: the console registers its tags as lazy stubs +// since its first load stopped carrying the package (objectstack#33581), and +// a stub carries no `inputs`, which is what this manifest is read from. +import '@object-ui/plugin-form'; const manifest = manifestFromConfigs( ComponentRegistry.getPublicConfigs() as unknown as Parameters[0], diff --git a/ui/apps/console/src/__tests__/public-contract.test.ts b/ui/apps/console/src/__tests__/public-contract.test.ts index 2ddbf531054..ff58cf76940 100644 --- a/ui/apps/console/src/__tests__/public-contract.test.ts +++ b/ui/apps/console/src/__tests__/public-contract.test.ts @@ -44,6 +44,11 @@ import { ComponentPropsMap } from '@objectstack/spec/ui'; import '@object-ui/components'; // … and the console's own plugin layer, from the module main.tsx boots from. import '../register-plugins'; +// `@object-ui/plugin-form` too: the console registers its tags as lazy stubs +// since its first load stopped carrying the package (objectstack#33581), and +// the reverse direction below reads `record:line_items`'s `inputs`, which a +// stub does not carry. `EXPECTED_LAZY` therefore stays the list it was. +import '@object-ui/plugin-form'; /** * Every curated tag the console makes available, in `PUBLIC_BLOCKS` order. diff --git a/ui/apps/console/src/__tests__/record-block-record-reach.test.tsx b/ui/apps/console/src/__tests__/record-block-record-reach.test.tsx index 1bde6f11388..2382b805240 100644 --- a/ui/apps/console/src/__tests__/record-block-record-reach.test.tsx +++ b/ui/apps/console/src/__tests__/record-block-record-reach.test.tsx @@ -85,6 +85,10 @@ import { // binding-reach probe: a hand-copied list would agree with itself. import '@object-ui/components'; import '../register-plugins'; +// `@object-ui/plugin-form` too: the console registers its tags as lazy stubs +// since its first load stopped carrying the package (objectstack#33581), and +// this probe renders `record:line_items` synchronously, through its real renderer. +import '@object-ui/plugin-form'; /** The object every probed block is mounted against. */ const PROBE_OBJECT = 'probe_object__c'; diff --git a/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts b/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts index 5a94a0d214e..0c98da696c7 100644 --- a/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts +++ b/ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts @@ -264,6 +264,11 @@ import { // test/hook timeout (AGENTS.md §测试纪律, objectui#3010). import '@object-ui/components'; import '../register-plugins'; +// `@object-ui/plugin-form` too: the console registers its tags as lazy stubs +// since its first load stopped carrying the package (objectstack#33581), and +// a stub carries no `inputs`, so without this import the three form blocks +// leave `covered`. +import '@object-ui/plugin-form'; // ── objectui#8176: the blocks `register-plugins` alone cannot show this gate ── // diff --git a/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx index c9527a6fd98..7b3d640abbb 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx @@ -90,6 +90,12 @@ vi.mock('./MetadataInspector', () => ({ useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }), })); +// The related list draws its rows through the registered `object-grid`. The +// console registers it in `register-plugins.ts`; this page reached it only +// through `@object-ui/plugin-view`'s entry until the shell took its view +// helpers from `@object-ui/plugin-view/core` (objectstack#33581), so the +// registration it renders through is loaded here, by name. +import '@object-ui/plugin-grid'; import { RecordDetailView } from './RecordDetailView'; /** diff --git a/ui/packages/app-shell/src/views/__tests__/FlowRunner.suspense.test.tsx b/ui/packages/app-shell/src/views/__tests__/FlowRunner.suspense.test.tsx index 805a02e8305..bf1d567ea34 100644 --- a/ui/packages/app-shell/src/views/__tests__/FlowRunner.suspense.test.tsx +++ b/ui/packages/app-shell/src/views/__tests__/FlowRunner.suspense.test.tsx @@ -27,14 +27,25 @@ import userEvent from '@testing-library/user-event'; let releaseForm: () => void = () => {}; const formLoaded = new Promise((resolve) => { releaseForm = resolve; }); +const FormBody = lazy(async () => { + await formLoaded; + return { default: ({ schema }: any) => }; +}); + +// `ObjectForm` is a component that suspends inside, as the real one does +// through its field widgets — not a `lazy()` itself: ScreenView takes it as the +// resolved value of its own `lazy()` (objectstack#33581), and React refuses a +// lazy that resolves to another lazy. vi.mock('@object-ui/plugin-form', async (importOriginal) => ({ ...(await importOriginal>()), - ObjectForm: lazy(async () => { - await formLoaded; - return { default: ({ schema }: any) => }; - }), + ObjectForm: (props: any) => , })); +// ScreenView now loads the form package itself, through `lazy()`, the first +// time a form screen is drawn (objectstack#33581). Its cold load is not what +// this pins, and it outlasts `waitFor`'s budget, so the (mocked) package is +// loaded here first; the body above still suspends on `formLoaded`. +await import('@object-ui/plugin-form'); const { FlowRunner } = await import('../FlowRunner'); const OBJECT_FORM_STATE = { diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/ScreenPreview.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/ScreenPreview.test.tsx index b1d5b4795f7..7f2da8c6719 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/ScreenPreview.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/ScreenPreview.test.tsx @@ -101,13 +101,16 @@ describe('ScreenPreview — flat fields', () => { }); describe('ScreenPreview — object-form mode', () => { - it('renders the runtime ObjectForm with the configured object/mode/defaults', () => { + // ScreenView draws `ObjectForm` through `lazy()` since the console's first + // load stopped carrying the form package (objectstack#33581), so the form + // appears a tick after the render: these two wait for it. + it('renders the runtime ObjectForm with the configured object/mode/defaults', async () => { render( , ); - expect(screen.getByTestId('object-form')).toBeInTheDocument(); + expect(await screen.findByTestId('object-form')).toBeInTheDocument(); const schema = objectFormSpy.mock.calls.at(-1)?.[0] as Record; expect(schema.type).toBe('object-form'); expect(schema.objectName).toBe('crm_account'); @@ -117,13 +120,14 @@ describe('ScreenPreview — object-form mode', () => { expect(screen.queryByRole('button', { name: 'Submit' })).not.toBeInTheDocument(); }); - it('passes derived master-detail subforms from the enriched object def to ObjectForm', () => { + it('passes derived master-detail subforms from the enriched object def to ObjectForm', async () => { // useMetadata().objects already carries `form.subforms` derived from inline-edit // relationships (attachInlineSubforms) — the preview just forwards them. objectsRef.current = [ { name: 'showcase_invoice', form: { subforms: [{ childObject: 'showcase_invoice_line', relationshipField: 'invoice', inlineMode: 'grid' }] } }, ]; render(); + await screen.findByTestId('object-form'); const schema = objectFormSpy.mock.calls.at(-1)?.[0] as Record; expect(schema.objectName).toBe('showcase_invoice'); expect(schema.subforms).toEqual([ From eeec690591a985504369f75f38cfa2bfd9de2774 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 22:57:24 +0000 Subject: [PATCH 4/7] chore(changeset): plugin-form and plugin-view /core subpaths, lazy form and view in the console Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- .../33581-plugin-form-view-core-subpaths.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .changeset/33581-plugin-form-view-core-subpaths.md diff --git a/.changeset/33581-plugin-form-view-core-subpaths.md b/.changeset/33581-plugin-form-view-core-subpaths.md new file mode 100644 index 00000000000..ac822aacda8 --- /dev/null +++ b/.changeset/33581-plugin-form-view-core-subpaths.md @@ -0,0 +1,20 @@ +--- +'@object-ui/plugin-form': patch +'@object-ui/plugin-view': patch +'@object-ui/app-shell': patch +'@object-ui/console': patch +--- + +perf(console): the first load stops downloading the form and view packages; `@object-ui/plugin-form/core` and `@object-ui/plugin-view/core` publish their pure helpers without registering anything + +Clause-②: yes (widening) — two new published `exports` subpaths, `@object-ui/plugin-form/core` and `@object-ui/plugin-view/core`, join what the packages accept; nothing is removed or renamed, and the package roots export the same names as before +Metadata-protocol: none + +`@object-ui/plugin-form` and `@object-ui/plugin-view` register their renderers with `ComponentRegistry` when their root entry is evaluated, and each root reaches every surface of its package. A host that imported one pure helper from the root therefore kept the whole package. Each package now publishes a `/core` subpath that registers nothing: + +- `@object-ui/plugin-form/core`: `filterSystemFields`, `isAutoGeneratedFieldType`, `isWideFieldType`, `inferColumns`, `containerGridColsFor`, `resolveInlineMode`, `omitServerResolvedDefaults`, `optionListDefault`, `resolveSectionGroupReferences`, `useInitialFieldFocus`, and the parameter types they take (`InlineMode`, `FieldDefaultsSchemaLike`, `OptionListFieldLike`, `ResolveSectionGroupsOptions`). +- `@object-ui/plugin-view/core`: `deriveRecordSurface`, `deriveRecordFlowSurface`, `overlayWidthFor`, `toFilterGroup`, `deriveFieldOptions`, `isImageLikeField`, `isGeoLikeField`, `pickPreferredField`, `KANBAN_GROUP_PREFERRED`, `PRIMARY_DATE_PREFERRED`, `END_DATE_PREFERRED`, and the types `RecordSurface`, `RecordFlowSurface`, `FieldOption`. + +The same names stay exported from each package root, unchanged; nothing to migrate. The subpath ships ESM only (`import`), as `@object-ui/plugin-chatbot/core` does. + +The console (`@object-ui/console`, and the shell it draws, `@object-ui/app-shell`) takes these helpers from the subpaths, draws the global record form, the action modal's form and a flow's object-form screen through `lazy()`, and registers the tags the two packages register (`object-form`, `view:form`, `embeddable-form`, `object-master-detail-form`, `record:line_items`, `object-view`, `view:simple`, `view-switcher`, `filter-ui`, `sort-ui`) as lazy stubs with the namespaces those registrations declare. Neither package is downloaded on the first load any more; each loads, and registers once, the first time a form or a view is drawn. What every page draws is unchanged; the first record form or action form opened in a session waits for the form chunk before it shows. From 9398a34a80b17bce3ba3f41d148a2ba09448903c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 23:00:47 +0000 Subject: [PATCH 5/7] fix(plugin-form,plugin-view): name the /core entry in the sideEffects array An entry form is always named, so a bundler keeps the subpath's module; the derived enumeration finds no registering module behind it. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- ui/packages/plugin-form/package.json | 2 ++ ui/packages/plugin-view/package.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ui/packages/plugin-form/package.json b/ui/packages/plugin-form/package.json index d59eb68b9df..e372fa392ee 100644 --- a/ui/packages/plugin-form/package.json +++ b/ui/packages/plugin-form/package.json @@ -8,8 +8,10 @@ "module": "dist/index.js", "types": "dist/index.d.ts", "sideEffects": [ + "./dist/core.js", "./dist/index.js", "./dist/index.umd.cjs", + "./src/core.ts", "./src/index.tsx" ], "exports": { diff --git a/ui/packages/plugin-view/package.json b/ui/packages/plugin-view/package.json index 69efe58e6e4..7cfe87b3f6b 100644 --- a/ui/packages/plugin-view/package.json +++ b/ui/packages/plugin-view/package.json @@ -8,8 +8,10 @@ "module": "dist/index.js", "types": "dist/index.d.ts", "sideEffects": [ + "./dist/core.js", "./dist/index.js", "./dist/index.umd.cjs", + "./src/core.ts", "./src/index.tsx" ], "exports": { From 8807ab36b34c5429a188dfa8e8e5ebe526935dd9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 23:09:16 +0000 Subject: [PATCH 6/7] test(ui-scripts): a secondary entry form in a sideEffects array is not judged for a load-time effect check-side-effects-array and this file's coverage direction both require every entry form in the array; a side-effect-free exports subpath is named for that reason, not as a claim that it registers. The barrel is still judged. Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- ...de-effects-declaration-consistency.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts b/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts index 5c33755671a..5e0a848af21 100644 --- a/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts +++ b/ui/scripts/__tests__/side-effects-declaration-consistency.test.ts @@ -915,6 +915,17 @@ function sourceBarrel(pkg: DeclaringPackage): string | undefined { return barrel === undefined ? undefined : path.join(repoRoot, pkg.dir, barrel); } +/** + * Whether `entry` is a source entry form of `pkg` other than its barrel: an + * `exports` subpath (or the in-repo alias of one) that a consumer imports as a + * separate entry point. + */ +function isSecondaryEntryForm(pkg: DeclaringPackage, entry: string): boolean { + const barrel = sourceBarrel(pkg); + const rel = barrel === undefined ? undefined : path.relative(path.join(repoRoot, pkg.dir), barrel).split(path.sep).join('/'); + return rel !== normalize(entry) && (entryForms.get(pkg.name) ?? []).includes(normalize(entry)); +} + /* -------------------------------------------------------------------------- */ /* The real-bundler probes (PR #3940's, hoisted and generalised). */ /* -------------------------------------------------------------------------- */ @@ -1390,6 +1401,13 @@ describe('`sideEffects` declarations match load-time behaviour (objectui#3943)', // the stylesheet, and running a TypeScript parser over it would report // "no top-level side effect" about a file that has no top level. .filter((entry) => isParseableModule(entry)) + // A SECONDARY entry form (an `exports` subpath beside the barrel, such + // as a side-effect-free `/core`) is named because it is an entry form: + // the coverage direction above and `check-side-effects-array.mjs` both + // require every entry form in the array, whatever its body does. It is + // not a claim that it does something on evaluation, so it is not + // judged here. The barrel still is. + .filter((entry) => !isSecondaryEntryForm(pkg, entry)) .filter((entry) => scanModule(path.join(repoRoot, pkg.dir, entry)).effects.length === 0) .map((entry) => `${pkg.name}: "${entry}" is declared in \`sideEffects\` but has no top-level side effect`), ); @@ -1422,6 +1440,17 @@ describe('`sideEffects` declarations match load-time behaviour (objectui#3943)', // barrel, and it is one of the three registrations the 2026-08-29 ruling // names as controls. expect(sourceEntries).toContain('@object-ui/app-shell/src/console/connect/ConnectAgentWidget.tsx'); + + // The secondary-entry exemption above reaches what it was written for + // (objectstack#33581's `/core` subpaths) and never a barrel. + const exempt = arrayPackages.flatMap((pkg) => + (pkg.declared as string[]) + .filter((entry) => isSourceEntry(pkg, entry) && isSecondaryEntryForm(pkg, entry)) + .map((entry) => `${pkg.name}/${normalize(entry)}`), + ); + expect(exempt).toContain('@object-ui/plugin-form/src/core.ts'); + expect(exempt).toContain('@object-ui/plugin-view/src/core.ts'); + expect(exempt.filter((e) => /\/src\/index\.[a-z]+$/.test(e))).toEqual([]); }); it('no array package declares a wildcard entry (this guard resolves literal paths)', () => { From e29406d9db7d2f2d0959b66e2bde90a3d491baad Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 23:09:54 +0000 Subject: [PATCH 7/7] test(ui-scripts): the multi-entry sideEffects population is the two /core subpaths Claude-Session: https://claude.ai/code/session_01ADHkmT5bCDp1MDcReXVCop Co-authored-by: Claude --- .../check-side-effects-array.test.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ui/scripts/__tests__/check-side-effects-array.test.ts b/ui/scripts/__tests__/check-side-effects-array.test.ts index 588d24ef73a..003e9770400 100644 --- a/ui/scripts/__tests__/check-side-effects-array.test.ts +++ b/ui/scripts/__tests__/check-side-effects-array.test.ts @@ -795,10 +795,20 @@ describe('the real workspace — the population this widening was measured again const kinds = results.flatMap((r) => r.entryForms.map((e) => e.kind)); expect(kinds).toContain('asset'); // @object-ui/app-shell's `./styles.css` expect(results.flatMap((r) => r.entryForms.flatMap((e) => e.alternateFormats)).length).toBeGreaterThan(0); - // ...and every package still walks from exactly one root, which is the - // sentence this change has to carry: the fix is right, and the genuine - // multi-entry population is ZERO today, so it is future packages the - // priority rests on rather than present ones. - for (const r of results) expect(r.entryPoints, r.name).toHaveLength(1); + // ...and the genuine multi-entry population is exactly the two `/core` + // subpaths objectstack#33581 published: side-effect-free secondary entry + // points, walked as roots of their own (and finding no registrar, which is + // their point). Every other package still walks from one root. A package + // joining or leaving this list is the moment to re-read the argument above. + const multi = Object.fromEntries( + results.filter((r) => r.entryPoints.length > 1).map((r) => [r.name, r.entryPoints]), + ); + expect(multi).toEqual({ + '@object-ui/plugin-form': ['src/core.ts', 'src/index.tsx'], + '@object-ui/plugin-view': ['src/core.ts', 'src/index.tsx'], + }); + for (const r of results) { + if (!(r.name in multi)) expect(r.entryPoints, r.name).toHaveLength(1); + } }); });