Skip to content

Commit 6f300df

Browse files
Copilothotlong
andcommitted
fix(build): replace dynamic require() with static imports in plugin-view, remove unused rest param in plugin-calendar
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/ddd5b726-e679-4ec8-9470-97f3ce913771
1 parent f36e244 commit 6f300df

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Fixed
1515

16+
- **CI Build Fix: Replace dynamic `require()` with static imports** (`@object-ui/plugin-view`): Replaced module-level `require('@object-ui/react')` calls in `index.tsx` and `ObjectView.tsx` with static `import` statements. The dynamic `require()` pattern is not supported by Next.js Turbopack, causing the docs site build to fail during SSR prerendering of the `/docs/components/complex/view-switcher` page with `Error: dynamic usage of require is not supported`. Since `@object-ui/react` is already a declared dependency and other files in the package use static imports from it, replacing the `require()` with static imports is safe and eliminates the SSR compatibility issue.
17+
18+
- **CI Build Fix: Remove unused `...rest` parameter** (`@object-ui/plugin-calendar`): Removed unused `...rest` destructured parameter from `ObjectCalendar` component props (TS6133), which caused the declaration file generation to emit a TypeScript error during the build.
19+
1620
- **CI Build Fix: Unused Parameters in Test Mocks** (`apps/console`): Fixed TypeScript `noUnusedParameters` errors (TS6133) in `ListToolbarActions.test.tsx` where mock component `props` parameters were declared but never used in `@object-ui/plugin-kanban` and `@object-ui/plugin-calendar` mocks, causing the console `tsc` build step to fail in CI.
1721

1822
- **i18n loadLanguage Not Compatible with Spec REST API Response Format** (`apps/console`): Fixed `loadLanguage` in `apps/console/src/main.tsx` to correctly unwrap the `@objectstack/spec` REST API envelope `{ data: { locale, translations } }`. Previously, the function returned the raw JSON response, which meant `useObjectLabel` and `useObjectTranslation` hooks received a wrapped object instead of the flat translation map, causing business object and field labels (e.g., CRM contact/account) to fall back to English. The fix extracts `data.translations` when the spec envelope is detected, while preserving backward compatibility with mock/dev environments that return flat translation objects. Includes 6 unit tests covering spec envelope unwrapping, flat fallback, HTTP errors, network failures, and edge cases.

packages/plugin-calendar/src/ObjectCalendar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export const ObjectCalendar: React.FC<ObjectCalendarProps> = ({
155155
onViewChange,
156156
onEventDrop,
157157
locale,
158-
...rest
159158
}) => {
160159
// When the parent (e.g. ObjectView) pre-fetches data and passes it via the `data` prop,
161160
// we must not trigger a second fetch. Detect external data by checking for an array.

packages/plugin-view/src/ObjectView.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,14 @@ import {
5757
} from '@object-ui/components';
5858
import { Plus } from 'lucide-react';
5959
import { buildExpandFields } from '@object-ui/core';
60+
import { SchemaRenderer as ImportedSchemaRenderer } from '@object-ui/react';
6061
import { ViewSwitcher } from './ViewSwitcher';
6162

6263
/**
63-
* Attempt to import SchemaRenderer from @object-ui/react.
64+
* SchemaRenderer from @object-ui/react, used to render sub-view schemas.
6465
* Falls back to null if not available.
6566
*/
66-
let SchemaRendererComponent: React.FC<any> | null = null;
67-
try {
68-
// eslint-disable-next-line @typescript-eslint/no-require-imports
69-
const mod = require('@object-ui/react');
70-
SchemaRendererComponent = mod.SchemaRenderer || null;
71-
} catch {
72-
// @object-ui/react not available
73-
}
67+
const SchemaRendererComponent: React.FC<any> | null = ImportedSchemaRenderer ?? null;
7468

7569
export interface ObjectViewProps {
7670
/**

packages/plugin-view/src/index.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import React, { useContext } from 'react';
1010
import { ComponentRegistry } from '@object-ui/core';
11+
import { SchemaRendererContext as ImportedSchemaRendererContext } from '@object-ui/react';
1112
import { ObjectView } from './ObjectView';
1213
import { ViewSwitcher } from './ViewSwitcher';
1314
import { FilterUI } from './FilterUI';
@@ -25,22 +26,11 @@ export type { SharedViewLinkProps } from './SharedViewLink';
2526

2627
/**
2728
* SchemaRendererContext is created by @object-ui/react.
28-
* We import it dynamically to avoid a circular dependency.
2929
* The context value provides { dataSource }.
30-
* A fallback context is created so hooks are never called conditionally.
30+
* A fallback context is used when the imported context is unavailable.
3131
*/
3232
const FallbackContext = React.createContext<any>(null);
33-
let SchemaRendererContext: React.Context<any> = FallbackContext;
34-
try {
35-
// eslint-disable-next-line @typescript-eslint/no-require-imports
36-
const mod = require('@object-ui/react');
37-
// The context is re-exported from @object-ui/react
38-
if (mod.SchemaRendererContext) {
39-
SchemaRendererContext = mod.SchemaRendererContext;
40-
}
41-
} catch {
42-
// @object-ui/react not available — registry-based dataSource only
43-
}
33+
const SchemaRendererContext: React.Context<any> = ImportedSchemaRendererContext ?? FallbackContext;
4434

4535
// Register object-view component
4636
const ObjectViewRenderer: React.FC<{ schema: any }> = ({ schema }) => {

0 commit comments

Comments
 (0)