Skip to content

Commit c9fb32c

Browse files
Copilothotlong
andcommitted
fix(fields): externalize @object-ui/i18n in vite.config.ts to fix SSR build
The fields package was bundling @object-ui/i18n (and its transitive react-i18next CJS code) into the dist output. During Next.js SSR prerendering, Turbopack would error with "dynamic usage of require is not supported" when loading LookupField. Fix: Convert the Vite external array to a regex-based function (consistent with @object-ui/components pattern) that matches @object-ui/i18n and all subpath imports. Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/05f829ca-088a-4d62-95c3-4f8ea8d78dce Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 187a48f commit c9fb32c

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- **Fields SSR build** (`@object-ui/fields`): Added `@object-ui/i18n` to Vite `external` in `vite.config.ts` and converted to regex-based externalization pattern (consistent with `@object-ui/components`) to prevent `react-i18next` CJS code from being bundled. Fixes `"dynamic usage of require is not supported"` error during Next.js SSR prerendering of `/docs/components/basic/text`.
1213
- **Console build** (`@object-ui/console`): Added missing `@object-ui/plugin-chatbot` devDependency that caused `TS2307: Cannot find module '@object-ui/plugin-chatbot'` during build.
1314
- **Site SSR build** (`@object-ui/site`): Added `@object-ui/i18n` to `transpilePackages` in `next.config.mjs` to fix "dynamic usage of require is not supported" error when prerendering the tooltip docs page. The i18n package is a transitive dependency of `@object-ui/react` and its `react-i18next` dependency requires transpilation for Turbopack SSR compatibility.
1415

packages/fields/vite.config.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@ export default defineConfig({
3030
fileName: (format) => `index.${format === 'es' ? 'js' : 'cjs'}`,
3131
},
3232
rollupOptions: {
33-
external: [
34-
'react',
35-
'react-dom',
36-
'react/jsx-runtime',
37-
'@object-ui/components',
38-
'@object-ui/core',
39-
'@object-ui/react',
40-
'@object-ui/types',
41-
'lucide-react',
42-
],
33+
external: (id) => /^(react|react-dom|@object-ui\/(components|core|i18n|react|types)|lucide-react)(\/|$)/.test(id),
4334
output: {
4435
globals: {
4536
react: 'React',

0 commit comments

Comments
 (0)