Skip to content

Commit 0eedfe7

Browse files
Copilothotlong
andcommitted
fix: restore src/ aliases in CI to fix "Unknown component type" runtime errors
Resolving from dist/ in CI caused plugin side-effect imports (ComponentRegistry.register) to silently fail on Vercel, resulting in "Unknown component type: object-grid" and similar runtime errors for kanban, calendar, and other plugins. Root cause: when Vite resolves plugins from pre-built dist/ bundles (instead of src/ via aliases), the ComponentRegistry singleton can get duplicated across Rollup chunks, so registrations happen on a different instance than the one SchemaRenderer queries. Fix: keep src/ aliases in ALL environments. The turbo build step is now removed from the Vercel buildCommand since Vite processes sources directly. Memory savings are still achieved by skipping compression and visualizer plugins in CI (~1.5 GB reduction). Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent e1b90d2 commit 0eedfe7

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

apps/console/vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://openapi.vercel.sh/vercel.json",
33
"installCommand": "cd ../.. && pnpm install --frozen-lockfile",
4-
"buildCommand": "cd ../.. && NODE_OPTIONS=--max-old-space-size=4096 pnpm turbo run build --filter=@object-ui/console^... --concurrency=3 && cd apps/console && pnpm msw:init && VITE_BASE_PATH=/ VITE_USE_MOCK_SERVER=true vite build",
4+
"buildCommand": "cd apps/console && pnpm msw:init && NODE_OPTIONS=--max-old-space-size=4096 VITE_BASE_PATH=/ VITE_USE_MOCK_SERVER=true vite build",
55
"outputDirectory": "dist",
66
"framework": "vite",
77
"rewrites": [

apps/console/vite.config.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ function preloadCriticalChunks(): Plugin {
4040
// auto-mount slug. Override with VITE_BASE_PATH only if deploying standalone.
4141
const basePath = process.env.VITE_BASE_PATH || '/console/';
4242

43-
// On Vercel/CI the turbo pipeline already builds every workspace package to
44-
// dist/ before Vite runs, so we can skip the memory-hungry src/ aliases and
45-
// let Vite resolve each @object-ui/* package through its normal package.json
46-
// "exports" → dist/. We also skip the compression and visualizer plugins
47-
// because the Vercel CDN handles gzip/brotli automatically and bundle analysis
48-
// is not needed during CI builds. Together this reduces peak memory by ~2 GB.
43+
// On Vercel/CI we skip the compression and visualizer plugins because the
44+
// Vercel CDN handles gzip/brotli automatically and bundle analysis is not
45+
// needed during CI builds. This reduces peak memory by ~1.5 GB.
46+
//
47+
// Workspace src/ aliases are kept in ALL environments (dev + CI) so that
48+
// plugin side-effect imports (ComponentRegistry.register) resolve correctly.
49+
// Without them, Vite would import pre-built dist/ bundles where the
50+
// singleton ComponentRegistry can get duplicated across chunks, causing
51+
// "Unknown component type" errors at runtime.
4952
const isCI = !!(process.env.VERCEL || process.env.CI);
5053

51-
// Workspace src/ aliases for local development — gives instant HMR without a
52-
// prior build step. Skipped in CI where turbo pre-builds everything to dist/.
53-
const localDevAliases: Record<string, string> = {
54+
// Workspace src/ aliases — gives instant HMR in dev and ensures correct
55+
// side-effect resolution (plugin registrations) in production builds.
56+
const workspaceAliases: Record<string, string> = {
5457
'@object-ui/components': path.resolve(__dirname, '../../packages/components/src'),
5558
'@object-ui/core': path.resolve(__dirname, '../../packages/core/src'),
5659
'@object-ui/fields': path.resolve(__dirname, '../../packages/fields/src'),
@@ -121,10 +124,7 @@ export default defineConfig({
121124
],
122125
resolve: {
123126
extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],
124-
// In CI/Vercel builds, all workspace packages are pre-built to dist/ by
125-
// turbo so Vite resolves them through package.json "exports". During local
126-
// dev, src/ aliases give us instant HMR without a prior build step.
127-
alias: isCI ? {} : localDevAliases,
127+
alias: workspaceAliases,
128128
},
129129
optimizeDeps: {
130130
include: [

0 commit comments

Comments
 (0)