Skip to content

objectui init scaffolds an app whose component registry is empty: generated src/App.tsx never imports @object-ui/components, so every node renders "Unknown component type" #4061

Description

@yinlianghui

Out-of-scope finding, measured while implementing #3892 (whose face is the scaffold's version ranges and its dead tailwind.config.js). Filed separately: the fix here is a change to the generated sources, outside #3892's completion scope.

Facts (verified on origin/main = 11c1e71e8)

packages/cli/src/commands/init.ts:568-573 generates the whole of src/App.tsx:

import{SchemaRenderer}from'@object-ui/react';importschemafrom'../app.json';exportdefaultfunctionApp(){return<SchemaRendererschema={schema}/>;}

That is the only @object-ui/* import the scaffold generates. Three facts make it insufficient:

  1. Registration is a side effect of importing @object-ui/components, and nothing else performs it. packages/components/src/index.ts:100-105 says so in as many words: // Export an init function to ensure components are registered// Simply importing this module should register all components.
  2. @object-ui/react does not depend on @object-ui/components. Its dependencies are @object-ui/core, @object-ui/data-objectstack, @object-ui/i18n, @object-ui/types, @objectstack/spec, react-hook-form — so importing SchemaRenderer pulls in no renderers.
  3. The renderer's miss path is visible, not silent.packages/react/src/SchemaRenderer.tsx:401 does const Component = ComponentRegistry.get(evaluatedSchema.type); and line 430 renders Unknown component type: {evaluatedSchema.type}.

So the registry a scaffolded project starts with is empty, and every node of the shipped templates — div, card, button, input, textarea, text — takes the miss path.

The manifest already declares@object-ui/components (init.ts:463-465 before #3892, buildInitPackageJson after it). It is declared and never imported: the exact defect direction #3755 removed from the sibling generator, here in the form where the declaration is the harmless half.

Compare: the temp-app generator does this correctly

utils/app-generator.ts:626+ generates an src/App.tsx that opens with nine imports, not one:

import{SchemaRenderer}from'@object-ui/react';import'@object-ui/components';import'@object-ui/plugin-charts';
...
import'@object-ui/plugin-view';

app-generator.test.ts then gates both directions (every import declared, every versioned declaration imported) over that generator's file map. commands/init.ts is the third generator and has never been under those gates — the same gap #3892 records for its version ranges.

Impact

objectui init is the first command an external user runs. npm install && npm run dev on its output renders a page of "Unknown component type" boxes for all three templates (simple, form, dashboard). Not dormant — it is the scaffold's entire visible output. Severity left to triage.

Not prejudging the fix

The undecided cell: whether the scaffold should import only @object-ui/components (matching what its three templates actually use — none of them names a plugin type) or the full nine-import block the temp-app generator writes (matching that generator, at the cost of nine dependencies for templates that use none of the plugins, which is #3755's direction again). The first looks closer to "declared = used"; the second keeps the two generators identical. Whichever is chosen, porting app-generator.test.ts's import/declaration gates onto the init file map is what stops it regressing — #3892 extends that file's anchor table to the init manifest but deliberately does not touch these two gates.

Dedup

Searched open issues in this repo: init scaffold plugin register components (0 hits), in:title init OR scaffold OR unstyled OR "@source" (#3907, #3892, #3884 — none on the generated sources). #3892 (in flight) is the version-range/tailwind.config.js face of the same file and does not touch src/App.tsx; #3852 and #3827 both scope to app-generator.ts.

Related: #3892.


Generated by Claude Code

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions