fix(runner): 把 vite 别名表补成工作区 import 的完整传递闭包 - #3599
Merged
Merged
Conversation
`packages/runner/vite.config.ts` 只别名了 7 个 `@object-ui/*`,但这些包的 `src` 自己又 import 了另外 8 个工作区包。没被别名的 specifier 退回 Node 解析、 落到 `packages/<pkg>/dist` —— 而 `dist` 只在构建之后存在,所以在只跑过 `pnpm install` 的干净 checkout 里,vite 报 "Failed to run dependency scan", 整条 import 链上的模块全部 500。这让 `content/docs/utilities/runner.mdx` 的 "From Source"(install → dev,没有 build 步骤)按文档操作必然失败。 别名表就是本仓选定的「runner 在 monorepo 内不依赖 dist 即跑」机制,表不完整 是该机制自身不变量的破缺。这里按传递闭包一次补齐,不是只补第一层: 第一层(#3575 已列):i18n / sdui-parser / react-runtime / fields / plugin-detail 第二层(补齐第一层后才可达):providers(<- fields)、permissions(<- plugin-detail) 类型级:data-objectstack(<- react/src/context/AppShellContext.tsx,`import type`, 被 esbuild 抹除,所以依赖扫描从来不报它,但它在闭包里) 表旁留了一行可复跑的闭包重导命令(已验证:当前表下输出为空即到达不动点; 人为拿掉两条时能准确报出缺口),并写明三个过滤器各自压掉的真实误报。 Fixes #3575 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
别名表没有按 `command` 分档,所以同样作用于 `vite build`(这是刻意的,与 apps/console 一致:插件包解析到 src 才能保证 ComponentRegistry 单例, 从各自 dist 引入则不保证)。补全闭包后 `@object-ui/fields` 等从 src 打包, `components/src/lib/lazy-icon.tsx` 经 `lucide-react/dynamic.mjs` 产生的 逐图标 chunk 不再被内联 —— 产物从 10 个 asset 变成 1776 个,其中约 1761 个 是 2KB 以下的图标微 chunk。这与 apps/console 的形状一致(其 build 配置注释 里就写着 "1700+ icon chunks")。 问题在于 vite 默认 `modulePreload: true` 会给每个 chunk 发一条 preload: 实测 index.html 从 546 B 涨到 145 KB、含 1765 条 `rel="modulepreload"`, 首屏就把所有图标 chunk 拉下来,懒加载反成劣化。console 正是为此关掉它, runner 同样需要。 关掉之后实测: index.html 546 B -> 542 B(1 条 preload -> 0 条) 首屏急切载荷 4231003 B -> 591795 B(-86%) dist 总大小 5064294 B -> 5343175 B(+5.5%,原先内联的图标变成独立文件) 产物可见变化,故补 patch changeset(runner 已发布,files 含 dist)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
marked this pull request as ready for review
August 7, 2026 15:25
This was referenced Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3575
问题
packages/runner/vite.config.ts只把 7 个@object-ui/*specifier 别名到packages/*/src,但这些包的src自己又 import 了另外一批工作区包。没进别名表的 specifier 退回 Node 解析、落到packages/PKG/dist—— 而dist只在构建之后存在。于是在只跑过pnpm install的干净 checkout 里,content/docs/utilities/runner.mdx的 "From Source"(install → dev,没有 build 步骤)必然失败。按 PM 分诊裁定走方向 1:别名表就是本仓已选定的「runner 在 monorepo 内不依赖 dist 即跑」机制,表不完整是该机制自身不变量的破缺。不动发布依赖面(方向 2),不让文档为机制的洞背锅(方向 3)。
闭包计算(不是只补第一层)
从
packages/runner/src出发,穿过每个被别名包的src,迭代到不动点。扫描前先剥掉注释 —— 本仓源码里大量在文档注释中引用@object-ui/...,不剥注释会把app-shell/plugin-grid/plugin-map等误判进来(实测三处均为注释)。闭包共 14 个包,其中 6 个已在表内(components / core / react / types / plugin-kanban / plugin-charts),新增 8 个:
@object-ui/i18nreact/src/index.ts、components/src/lib/close-label.tsx@object-ui/sdui-parsercomponents/src/renderers/layout/page.tsx@object-ui/react-runtimecomponents/src/renderers/layout/react-page.tsx@object-ui/fieldsplugin-kanban/src/ObjectKanban.tsx@object-ui/plugin-detailplugin-kanban/src/ObjectKanban.tsx@object-ui/providersfields/src/widgets/FileField.tsx、ImageField.tsx@object-ui/permissionsplugin-detail/src/DetailView.tsx等 6 个文件@object-ui/data-objectstackreact/src/context/AppShellContext.tsxproviders/permissions)只有在第 1 层解析到 src 之后才可达 —— issue 里列的 5 个是第一层,只补它们会把洞往下挪一层。data-objectstack是import type,esbuild 会抹除,所以依赖扫描从来不报它;它按不变量属于闭包,提前别名,免得哪天该 import 变成值导入时 dev server 才炸。@object-ui/x/y),无工作区包的真实 CSS@import—— 三处疑似命中经核实全在注释里。表旁留了可复跑的闭包重导命令
一条
comm -13单行命令,拿别名表自身当输入,再跑一遍即可确认是否还有缺口。已实测:fields/i18n两条从表里去掉,能准确报出这两个缺口。注释里逐条写明三个过滤器各自压掉的真实误报(
@import文档注释、JSDoc 里的import()示例、以及指向已不存在目录的表项)。验证(方向在跑之前先定)
干净 worktree,只
pnpm install,不 build,自选空闲端口--strictPort。BEFORE(预测红,实测红)
issue 里那条
@fs探针连同另外 5 个文件全部 500:Failed to resolve import "@object-ui/i18n" from "../components/src/renderers/basic/elements.tsx"。顺带测到:
pnpm --filter @object-ui/runner build在同样状态下也是失败的 —— 这个洞不止影响 dev:AFTER(预测绿,实测绿)
依赖扫描零 unresolved(日志里
could not be resolved/Failed to run dependency scan出现 0 次)。没有停在点探针上 —— 直接从/src/main.tsx沿 vite 改写后的 import URL 爬了整张模块图:13 而非 14,差的正是类型级的
data-objectstack(被 esbuild 抹除,本就不进模块图)—— 与分析自洽。issue 原探针elements.tsx500 → 200。@object-ui/react是@object-ui/react-runtime的前缀,但 rollup alias 要求匹配pattern + "/",故未被吞掉 ——react-page.tsx与react-runtime/src/index.ts均 200,已实测钉住。未跑无头浏览器:容器内没装 playwright 浏览器(
~/.cache/ms-playwright不存在),所以没有白屏/渲染截图这一层,只有 HTTP 模块图这一层。构建路径的影响 + changeset 决策
别名表没有按
command分档,因此同样作用于vite build。这是刻意的,与apps/console一致(其注释写明:插件包解析到 src 才能保证 ComponentRegistry 单例,从各自 dist 引入则不保证,否则会出 "Unknown component type")。把依赖都构建好(等价 CI 状态)后对比:
modulePreload: false)rel="modulepreload"条数@object-ui/fields等从 src 打包后,components/src/lib/lazy-icon.tsx经lucide-react/dynamic.mjs产生的逐图标 chunk 不再被内联,产物变成约 1761 个 2KB 以下的图标微 chunk。这与 console 的形状一致 —— console 的 build 配置注释里就写着 "1700+ icon chunks"。但 vite 默认
modulePreload: true会给每个 chunk 发一条 preload,首屏就把图标全拉下来,懒加载反成劣化。console 正是为此关掉它,runner 同样需要,故本 PR 一并关掉;这是本次改动自身引入的回归,不是顺手修的无关问题。关掉后首屏急切载荷从 4.2 MB 降到 0.59 MB。产物可见变化(runner 已发布,
files含dist),故补了 patch changeset —— 与派单里「若影响发布产物解析则需 patch changeset」的判据一致。其它
pnpm --filter @object-ui/runner type-check/lint/test:全绿(9 tests passed;lint 23 条既有 warning、0 error)。node scripts/check-control-bytes.mjsOK,并对改动文件另做了控制字符自扫。vite.config.ts不在 runner 的 tsc program 里(include: ["src"]),所以 type-check 覆盖不到本文件;真正的验收证据是上面的 dev/build 实测。@object-ui/data-objectql指向的packages/data-objectql/目录并不存在,且该 specifier 全仓仅此一处引用。属同一张表另一个方向的破缺,是独立缺陷,本 PR 未动,已按 Prime Directive [WIP] Enhance every detail of the designer #10 另开 packages/runner/vite.config.ts 的 @object-ui/data-objectql 别名指向不存在的包目录(全仓唯一引用) #3593(observation-class,休眠:无人 import,故今天不影响任何人)。本 PR 的重导命令用2>/dev/null容忍它并在注释里点名了该单。Generated by Claude Code