Uh oh!
There was an error while loading. Please reload this page.
fix(plugin-map): 删掉模块作用域遗留的 console.log('Registering object-map...') (objectstack#7139) - #4007
Merged
Merged
Conversation
…(objectstack#7139)
`packages/plugin-map/src/index.tsx` 注册调用之前留着一句调试输出,位于模块作用域 ——
只要这个 plugin 被 import 就打一行:console 的 register-plugins 一加载即触发,
单元测试里跟着刷,生产 bundle 同样保留。同仓其余 18 个 plugin 的注册处都没有这类
输出,这一句是孤例。纯噪音,不涉及行为。
回潮钉 src/index.registration.test.tsx:spy console.log/info/debug 后
vi.resetModules() 再 import('./index'),断言零输出。刻意只覆盖这三个噪音通道,
不含 warn/error —— ComponentRegistry.register() 在缺 namespace 与裸名 fallback
冲突时按设计会 console.warn,一刀切等于把 Registry 的诊断契约钉在这里。钉子含
非空断言(import 后校验两个注册确实进了 registry),避免模块缓存导致假绿。
Co-authored-by: Claude <noreply@anthropic.com>The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
commented
Aug 9, 2026
CollaboratorAuthor
PM 验收(session_01GTRjn8xBqp75dk7kFupVRt):通过,转 ready 并挂 auto-merge。objectstack#7139 落地 —— 模块作用域遗留 console.log 删除 + 防回潮钉。 核验记录(head
out-of-scope objectstack#7146(eslint 未开 no-console,拦网缺失类 finding,自评「当前仓库干净」诚实)由 PM 分诊轮处理。 Generated by Claude Code |
yinlianghui
marked this pull request as ready for review
August 10, 2026 00:08
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Fixesobjectstack-ai/objectstack#7139
问题
packages/plugin-map/src/index.tsx在两处ComponentRegistry.register调用之前留着一句调试输出:它位于模块作用域,所以不是「渲染地图时打一行」,而是只要这个 plugin 被 import 就打一行:console 应用的
register-plugins一加载即触发,单元测试里跟着刷,生产 bundle 同样保留 —— 使用者控制台里凭空多出一行来源不明的噪音。纯噪音,不涉及任何行为:注册本身、ObjectMap的渲染与取数都不读它。孤例已核实:遍历同仓 19 个
packages/plugin-*/src/index.tsx,只有 plugin-map 有这句。plugin-editor里唯一的console.log命中是defaultProps.value里的示例代码字符串,不是会执行的语句。前提复核(issue 正文是线索,不是规格)
issue 说的是第 24 行,实际在
origin/main上已经是第 64 行 —— objectstack#7121 的 dataSource 绑定(commit 022002a)在它上方插入了注释与代码。行号漂移,但结论成立:这句console.log确实还在模块作用域。基线 sha 见下。改动
dataSource绑定零触碰。packages/plugin-map/src/index.registration.test.tsx。关于钉子的两个刻意取舍
只覆盖 log / info / debug 三个「噪音通道」,不含 warn / error。
ComponentRegistry.register()在缺 namespace、以及裸名 fallback 覆盖冲突时按设计会console.warn(见packages/core/src/registry/Registry.ts)。一刀切断言「零 console 输出」等于把 Registry 的诊断契约钉在 plugin-map 这里,将来会因与「遗留调试输出」完全无关的原因变红。要钉的缺陷类就是遗留调试输出本身。另外ObjectMap.tsx里三处console.warn/console.error是有意保留的运行时诊断,同理不该被这条钉子牵连。含一条非空断言。 import 之后校验
object-map(namespaceplugin-map)与map(namespaceview)两个注册确实进了 registry。没有这条,一旦模块缓存导致import未真正执行,「没有输出」就会是因为什么都没发生而假绿 —— 断言通过的原因是错的。配套用vi.resetModules()保证模块体在 spy 之下重新求值,解决 import 不可重放的问题。反向验证(方向先判后跑)
预判方向:保留 console.log 时钉子必须红,因为断言直接指向被删语句的唯一效果,不存在反转可能。实跑一致 —— 先在未修改的
index.tsx上跑钉子:红,且原样抓到被删语句的 payload;两条 registry 非空断言在它之前先通过,证明模块体确实执行了(不是空跑假红)。删掉该行后转绿。
验证
pnpm exec vitest run packages/plugin-map --maxWorkers=2→ 4 files / 11 tests 全绿pnpm exec turbo run type-check --concurrency=2→ 78 successful, 78 totalpnpm --filter @object-ui/plugin-map lint→ 0 errors(58 条既有 warning,新增测试文件零命中)node scripts/check-control-bytes.mjs→ OK(3910 tracked text files)changeset:
.changeset/plugin-map-drop-module-scope-console-log-7139.md(patch)。超范围发现(未在本 PR 修)
仓库 eslint 配置没有开
no-console规则,所以这类遗留调试输出没有任何自动化拦网,这次靠人工发现。是否全仓开启(以及ObjectMap.tsx那三处有意保留的诊断如何豁免)是影响多个包的策略决定,不该混进这个 XS 单 —— 另行开单交 PM 分诊。Generated by Claude Code