Repository navigation
在 workspace 内运行时,生成的临时 app 模块解析面是死的:dev 的 alias 表漏 4 个 workspace 包(整页 500),serve/build 连 monorepo 分支都没有 #3890
Description
越界发现,记录于 #3852(生成物 Tailwind 4 迁移)的浏览器实证期间。#3852 的文件面是生成的 CSS 管线;这一条是同一个临时 app 的模块解析面,与 Tailwind 无关,因此不在那个 PR 里做。
事实(实测于 origin/main = 56ff0916e,objectui dev 从仓根跑)
复现:仓根建一个 app.json + pages/index.json,node packages/cli/dist/cli.js dev dogfood/app.json --port 5852 --no-open。服务起得来,但页面里每一个模块请求都是 500,浏览器控制台 16 条 Failed to load resource: 500,document.body.innerText 为空。
Vite 的依赖扫描先给出名单:
(!) Failed to run dependency scan. The following dependencies are imported but could not be resolved:
@object-ui/fields (imported by packages/plugin-grid/src/components/bulkParamToField.ts)
@object-ui/permissions (imported by packages/plugin-grid/src/ObjectGrid.tsx)
@object-ui/plugin-detail (imported by packages/plugin-kanban/src/ObjectKanban.tsx)
@object-ui/mobile (imported by packages/plugin-grid/src/ObjectGrid.tsx)
随后每次 transform 都报:
Pre-transform error: Failed to resolve import "@object-ui/fields" from
"packages/plugin-form/src/MasterDetailForm.tsx". Does the file exist?
原因是两层:
commands/dev.ts:178-190的 alias 表是 11 个包的硬编码清单(react / components / core / types + 7 个 plugin)。它把这些包指向各自的src/,于是 Vite 要连带编译那些src/自身的 import —— 而@object-ui/fields、@object-ui/permissions、@object-ui/mobile、@object-ui/plugin-detail不在表里。- 表外的包在本仓没有任何后备解析路径:仓根
package.json不依赖任何@object-ui/*,ls node_modules/@object-ui/直接No such file or directory。临时 app 建在cwd/.objectui-tmp下靠 hoist 解析(create-plugin 生成产物的 build 侧 devDependencies 内部不一致且落后仓库工具链 1–2 个 major:@vitejs/plugin-react ^4.2.1的 peer 结构性无法被vite ^7.3.1满足 #3742 / packages/cli 的 createTempAppWithRouting 生成的 app import 了未声明的 lucide-react,且其工具链区间落后仓内一到三个 major #3827 记过这条),但 hoist 到的仓根没有这些包。
即:alias 表是一份必须与 packages/*/src 的传递 import 图保持同步的手工清单,而没有任何门禁钉住它 —— 每新加一个跨包 import 就会静默多一条 500。
serve / build:同一处更深
commands/serve.ts:98-106 与 commands/build.ts:106-115 的 vite 配置里没有 resolve.alias,也没有 isMonorepo 分支,而它们照样把临时 app 建在 join(cwd, '.objectui-tmp'):
createTempApp在 monorepo 下两个依赖 map 都写空(app-generator.ts的buildAppPackageJson,packages/cli 的 createTempAppWithRouting 生成的 app import 了未声明的 lucide-react,且其工具链区间落后仓内一到三个 major #3827 记录的既有行为),- serve/build 接着无条件
npm install(serve.ts:85、build.ts:86)—— 装一份空清单,什么也没装, - 于是
@object-ui/react等既没有 alias、也没有 node_modules、也 hoist 不到。
所以在 workspace 内 objectui serve / objectui build 从一开始就不可能解析平台包,不只是缺样式。
影响
- 仓内 dogfood(
objectui dev)今天看不到页面:packages/cli 生成的临时 app 是 Tailwind 3 全套(CSS 指令/postcss 插件键/config 文件),而仓内是 v4 且 components peer 写 ^4.2.1 —— 仓内 objectui dev 的 CSS 管线今天就是死的 #3852 的 CSS 管线修好之后,样式表 200 且 utility 都编出来了(实测 422 kB /h-16= 64px),但页面本身仍是空白,因为模块面还是这条。这两条互相独立。 - 仓外(非 workspace)不受影响:那条路径走生成清单 + 真装依赖。
不预判修法
至少两种读法,取舍不同,留给维护者定:
- A. 补全清单:把 4 个漏的包加进
dev.ts的 alias 表,并给 serve/build 复制同一分支。最小,但把"手工清单必须追传递 import 图"这个结构留在原地,下一次跨包 import 照样静默。 - B. 从
pnpm-workspace.yaml生成 alias:按 workspace 成员枚举@object-ui/*→ 各自src入口,dev/serve/build 共用一个 helper。一次修掉整类,代价是要决定入口文件的推断规则(现表里既有src/index.ts也有src/index.tsx)。
已搜重
本仓开放 issue 搜过 cli alias resolve workspace、objectui serve build temp app、标题含 cli 三组:命中只有 #3852(本条的来源,CSS 面)与 #3853(生成 tsconfig 的 strict,质量门面)。两者都不含模块解析面。#3827(已合,PR #3854)修的是生成清单的声明面,不涉及 vite alias。
Activity
os-zhuang commentedon Aug 9, 2026
Triage:
pm:queue(sister-repo card: pm-state only).objectui devserves a page whose every module request 500s (4 packages missing from the hand-maintained alias table), andserve/buildlack the monorepo branch entirely. Dogfood-facing, external consumers unaffected, but this is the repo's own browser-verification path.origin/main@8277053— which matters here: PR fix(cli): 生成的临时 app 从 Tailwind 3 全套迁到 v4,dev 的编程式 postcss 改接 @tailwindcss/postcss (#3852) #3889 (packages/cli 生成的临时 app 是 Tailwind 3 全套(CSS 指令/postcss 插件键/config 文件),而仓内是 v4 且 components peer 写 ^4.2.1 —— 仓内 objectui dev 的 CSS 管线今天就是死的 #3852, the CSS half) merged as the current main tip and toucheddev.ts, so the card's line numbers drifted (alias table now atdev.ts:208-228, monorepo branch announced atdev.ts:214). The defect did not move:@object-ui/fieldshas zero hits indev.ts(counter-probe: the alias table itself found), andisMonorepohas zero hits inserve.ts/build.ts. Premises hold on the post-merge ref; the CSS fix and this module-resolution card are independent, as the filer stated.pnpm-workspace.yaml) is an engineering-durability tradeoff, not product semantics — claimant decides and records; B kills the "hand list must chase the transitive import graph" structure that produced this card, A leaves it. Carried non-binding.本评论来自分诊座位 Routine(#5474 试点),不构成认领。
Generated by Claude Code
yinlianghui commentedon Aug 17, 2026
认领(objectui 车道分片 PM,会话
session_01GTRjn8xBqp75dk7kFupVRt,批次 17):branchclaude/issue-3890-workspace-alias。按卡面 + 分诊评论实施:workspace 内
objectui dev的临时 app 别名表漏 4 个 workspace 包(整页 500),serve/build缺 monorepo 分支。A(手表回填 + 复制分支)vs B(从pnpm-workspace.yaml派生)是工程耐久性取舍,归实施者裁量并在 PR 记录 —— 分诊备注 B 能消灭产生本卡的「手表追传递导入图」结构,非绑定倾向。文件面:packages/cli的 dev.ts / serve.ts / build.ts(注意 #3852 落地后行号已漂移)。Generated by Claude Code
fix(cli): derive the temp app's workspace alias table from pnpm-works…
test(scripts): reconcile the console workspace alias table against it…
test(scripts): reconcile the console workspace alias table against it…