Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… debugging - Add ConsolePlugin to objectstack.config.ts plugins array for CLI-based serving - Add `dev` script for development mode with hot-reload and Studio UI - Add `plugin.ts` with CRMPlugin class for importing as a plugin in other projects - Add `./plugin` export path in package.json for plugin consumption - Update server.ts to import ConsolePlugin directly from @object-ui/console - Add `type: module` to package.json for ESM compatibility Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Enables examples/crm to run via the ObjectStack CLI with the Console UI auto-loaded, and adds a reusable ./plugin export for consuming CRM metadata (and a plugin wrapper) from other projects.
Changes:
- Add
ConsolePluginto the CRM stack config soobjectstack serveloads the Console UI automatically. - Add a new
plugin.tsentrypoint exportingCRMPluginandcrmConfig. - Update
package.jsonscripts/exports and alignserver.tsto importConsolePluginfrom@object-ui/console.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/crm/objectstack.config.ts | Imports and registers ConsolePlugin in the exported stack config. |
| examples/crm/package.json | Adds type: module, dev script, and ./plugin export. |
| examples/crm/plugin.ts | Adds CRMPlugin wrapper and crmConfig export. |
| examples/crm/server.ts | Switches ConsolePlugin import to @object-ui/console. |
| examples/crm/tsconfig.json | Includes the new plugin.ts in compilation. |
| import config from './objectstack.config'; | ||
|
|
||
| /** Raw CRM stack configuration for direct merging */ | ||
| export const crmConfig = config; |
There was a problem hiding this comment.
plugin.ts imports and re-exports objectstack.config.ts as crmConfig. Since objectstack.config.ts now includes new ConsolePlugin() (Node-only), any consumer that imports crmConfig/CRMPlugin will also pull in the console’s Node built-ins. If the goal is to share CRM metadata, consider exporting a metadata-only config (no runtime plugins) from ./plugin and keeping runtime UI plugins in a separate Node-only entrypoint.
| }, | ||
| plugins: [ | ||
| new ConsolePlugin(), | ||
| ], |
There was a problem hiding this comment.
objectstack.config.ts now imports ConsolePlugin from @object-ui/console and instantiates it in the exported config. @object-ui/console's plugin implementation imports Node-only built-ins (fs, path, url), and this CRM config is imported in browser contexts (e.g. Storybook’s .storybook/msw-browser.ts imports @object-ui/example-crm → objectstack.config.ts). This will make browser bundling/runtime fail. Consider keeping objectstack.config.ts as pure metadata (objects/apps/manifest) and moving ConsolePlugin to a Node-only runtime config entrypoint (e.g. a separate objectstack.runtime.config.ts used by pnpm dev/serve) or loading the console plugin conditionally so the metadata package remains browser-safe.
| async start(ctx: any) { | ||
| const logger = ctx.logger || console; | ||
|
|
||
| try { | ||
| // Dynamically import AppPlugin to keep plugin.ts dependency-light | ||
| const { AppPlugin } = await import('@objectstack/runtime'); | ||
| const appPlugin = new AppPlugin(config); | ||
| await ctx.kernel?.use?.(appPlugin); | ||
| logger.info('[CRM] Metadata loaded: objects, apps, dashboards, seed data'); | ||
| } catch (e: any) { | ||
| logger.warn(`[CRM] Could not auto-register via AppPlugin: ${e.message}`); | ||
| logger.info('[CRM] Config is available via crmConfig export for manual merging'); |
There was a problem hiding this comment.
In start(), await ctx.kernel?.use?.(appPlugin) will silently do nothing when ctx.kernel (or use) is missing, but the code still logs "Metadata loaded" as if registration succeeded. This can lead to false-positive startup logs and a non-functional plugin. Consider validating that ctx.kernel exists and supports use() before logging success; otherwise log a warning/error and return (or throw) so failures are visible.
Reference: objectstack-ai/objectui#506 - Add ConsolePlugin to objectstack.config.ts plugins array - Add ConsolePlugin to Vercel serverless handler - Add @object-ui/console ^3.0.1 as devDependency - Update dev script to use `objectstack serve --dev` - Add `serve` script for production CLI mode Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Enable
examples/crmto work as both a standalone debuggable app (via CLI) and a reusable plugin for other projects.CLI Development Modes
pnpm dev—objectstack serve --devwith auto MemoryDriver, Studio UI, and ConsolePluginpnpm serve— production mode via CLI, ConsolePlugin loaded from configpnpm start— customtsx server.tswith explicit auth, logging, full controlConsole Integration
ConsolePluginadded toobjectstack.config.tsplugins array so the CLIservecommand loads the Console UI automatically — no custom server.ts needed for basic usage.Plugin Export
New
plugin.tswithCRMPluginclass andcrmConfigraw export, exposed via./pluginpackage export:Changes
objectstack.config.ts— embedConsolePlugininpluginsarray (usesas anysincedefineStackschema doesn't include runtime plugins, consistent withobjectstack.shared.ts)package.json— adddevscript,type: module,./pluginexport pathplugin.ts— newCRMPluginclass wrapping CRM metadata as kernel-compatible pluginserver.ts— importConsolePlugindirectly from@object-ui/consoletsconfig.json— includeplugin.tsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.