Skip to content

[WIP] Fix component registration issue in documentation page#137

Merged
huangyiirene merged 2 commits intomainfrom
copilot/fix-unknown-component-error
Jan 21, 2026
Merged

[WIP] Fix component registration issue in documentation page#137
huangyiirene merged 2 commits intomainfrom
copilot/fix-unknown-component-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 21, 2026

Fix Icon Component Not Displaying in Documentation

Root Cause

The icon component and all other components were showing "unknown component type" error in the documentation because:

  1. Component registration wasn't executing: The Vite build was bundling @object-ui/core into the components package, causing the ComponentRegistry singleton to not work properly across module boundaries.
  2. Icon name lookup was failing: Lucide React exports icons in PascalCase (e.g., "Home", "Star"), but the schema uses kebab-case names (e.g., "home", "star").

Changes Made

  • Identify root cause of component registration failure
  • Fix Vite build configuration to externalize @object-ui/core, @object-ui/react, and @object-ui/types
  • Add sideEffects: true to components package.json to prevent tree-shaking
  • Add initializeComponents() export function to ensure registration
  • Update icon component to convert kebab-case to PascalCase for Lucide icon lookup
  • Add proper handling for icon component size, color, and className properties
  • Add displayName to IconRenderer component
  • Update ObjectUIProvider to call initializeComponents()
  • Test icon component displays correctly in documentation
  • Verify all components are registered properly

Technical Details

Icon Component Enhancement:

  • Added toPascalCase() utility to convert names like "arrow-right" → "ArrowRight"
  • Properly extracts and applies designer props (data-obj-id, data-obj-type)
  • Handles size property for custom dimensions
  • Merges color and className properties correctly
  • Adds warning when icon not found

Build Configuration:

  • Made workspace packages (@object-ui/core, @object-ui/react, @object-ui/types) external in Vite build
  • This ensures the ComponentRegistry singleton works correctly across all packages
  • Added sideEffects: true to prevent bundlers from tree-shaking registration code

Result

✅ All components now register and display correctly in the documentation
✅ Icon component properly renders Lucide icons
✅ Component registry shows 70+ registered components

Original prompt

文档的组件页面,组件不能显示,应该是组件没有注册 unknown component type: icon ...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
objectui-docs Error Error Jan 21, 2026 4:41pm
objectui-site Error Error Jan 21, 2026 4:41pm

Request Review

@huangyiirene
Copy link
Copy Markdown
Contributor

@copilot 文档的组件页面,每个组件都不能显示,应该是组件都没有注册 unknown component type

- Updated icon component to properly convert kebab-case names to PascalCase for Lucide lookup
- Fixed component registration by making @object-ui/core external in Vite build
- Added `sideEffects: true` to package.json to prevent tree-shaking
- Added explicit initializeComponents() export to ensure registration
- Enhanced icon component to handle size, color, and className properties properly
- Updated Next.js config to remove unnecessary transpilePackages configuration

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
@vercel vercel Bot temporarily deployed to Preview – objectui-docs January 21, 2026 16:41 Inactive
@huangyiirene huangyiirene marked this pull request as ready for review January 21, 2026 16:42
@huangyiirene huangyiirene merged commit 72754d9 into main Jan 21, 2026
7 of 12 checks passed
Copilot AI requested a review from huangyiirene January 21, 2026 16:43
Copilot stopped work on behalf of huangyiirene due to an error January 21, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants