Skip to content

fix(plugin-map): 删掉模块作用域遗留的 console.log('Registering object-map...') (objectstack#7139) - #4007

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-7139-plugin-map-console-log
Aug 10, 2026
Merged

fix(plugin-map): 删掉模块作用域遗留的 console.log('Registering object-map...') (objectstack#7139)#4007
yinlianghui merged 1 commit into
mainfrom
claude/issue-7139-plugin-map-console-log

Conversation

@yinlianghui

Copy link
Copy Markdown
Collaborator

Fixesobjectstack-ai/objectstack#7139

问题

packages/plugin-map/src/index.tsx 在两处 ComponentRegistry.register 调用之前留着一句调试输出:

console.log('Registering object-map...');

它位于模块作用域,所以不是「渲染地图时打一行」,而是只要这个 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 见下。

改动

  1. 删掉那一行。同文件 objectstack#7121 刚落的 dataSource 绑定零触碰
  2. 防回潮钉 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(namespace plugin-map)与 map(namespace view)两个注册确实进了 registry。没有这条,一旦模块缓存导致 import 未真正执行,「没有输出」就会是因为什么都没发生而假绿 —— 断言通过的原因是错的。配套用 vi.resetModules() 保证模块体在 spy 之下重新求值,解决 import 不可重放的问题。

反向验证(方向先判后跑)

预判方向:保留 console.log 时钉子必须红,因为断言直接指向被删语句的唯一效果,不存在反转可能。实跑一致 —— 先在未修改index.tsx 上跑钉子:

AssertionError: expected [ Array(1) ] to deeply equal []
- []
+ [ "console.log([\"Registering object-map...\"])" ]

红,且原样抓到被删语句的 payload;两条 registry 非空断言在它之前先通过,证明模块体确实执行了(不是空跑假红)。删掉该行后转绿。

验证

  • pnpm exec vitest run packages/plugin-map --maxWorkers=24 files / 11 tests 全绿
  • 仓根 pnpm exec turbo run type-check --concurrency=278 successful, 78 total
  • pnpm --filter @object-ui/plugin-map lint0 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

…(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>
@vercel

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectuiIgnoredIgnoredAug 9, 2026 11:16pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

MetricValueBudget
Main entry (gzip)28.1 KB350 KB
Entry fileindex-DIOf6Ju7.js
StatusPASS

📦 Bundle Size Report

PackageSizeGzipped
app-shell (index.js)8.66KB3.13KB
app-shell (runtime-config.js)7.42KB2.32KB
app-shell (types.js)0.01KB0.04KB
app-shell (urlParams.js)7.57KB2.97KB
auth (AuthContext.js)0.31KB0.24KB
auth (AuthGuard.js)1.17KB0.53KB
auth (AuthProvider.js)22.10KB4.37KB
auth (AuthShell.js)3.49KB1.40KB
auth (ForgotPasswordForm.js)12.21KB3.45KB
auth (LoginForm.js)18.13KB5.39KB
auth (PreviewBanner.js)0.90KB0.50KB
auth (RegisterForm.js)6.64KB2.21KB
auth (SocialSignInButtons.js)9.60KB3.89KB
auth (UserMenu.js)3.40KB1.22KB
auth (auth-gate-events.js)1.29KB0.66KB
auth (authStyles.js)5.04KB1.72KB
auth (createAuthClient.js)35.76KB9.11KB
auth (createAuthenticatedFetch.js)4.37KB1.69KB
auth (index.js)2.35KB1.07KB
auth (org-roles.js)6.66KB2.78KB
auth (phone-identifier.js)1.11KB0.66KB
auth (types.js)0.59KB0.35KB
auth (useAuth.js)4.91KB0.87KB
auth (useIsWorkspaceAdmin.js)1.61KB0.85KB
collaboration (CommentThread.js)26.07KB7.56KB
collaboration (LiveCursors.js)3.17KB1.27KB
collaboration (PresenceAvatars.js)6.49KB2.64KB
collaboration (PresenceProvider.js)2.79KB1.13KB
collaboration (index.js)1.65KB0.73KB
collaboration (useCollaborationTranslation.js)6.05KB2.52KB
collaboration (useCommentSearch.js)1.98KB0.88KB
collaboration (useConflictResolution.js)7.75KB1.86KB
collaboration (useMentionNotifications.js)1.81KB0.68KB
collaboration (usePresence.js)6.33KB1.84KB
collaboration (useRealtimeSubscription.js)7.91KB2.01KB
components (index.js)483.72KB106.71KB
core (index.js)3.00KB1.14KB
create-plugin (index.js)10.08KB3.26KB
data-objectstack (index.js)139.61KB35.99KB
fields (index.js)228.44KB56.66KB
i18n (LocalizationContext.js)1.76KB0.96KB
i18n (currency.js)1.22KB0.64KB
i18n (i18n.js)4.32KB1.77KB
i18n (index.js)2.65KB1.06KB
i18n (pickLocalized.js)1.70KB0.83KB
i18n (provider.js)9.48KB3.27KB
i18n (useObjectLabel.js)27.59KB6.63KB
i18n (useSafeTranslation.js)4.52KB1.96KB
layout (index.js)38.84KB10.80KB
mobile (MobileProvider.js)0.92KB0.49KB
mobile (ResponsiveContainer.js)0.94KB0.38KB
mobile (breakpoints.js)1.51KB0.70KB
mobile (createOfflineDataSource.js)5.61KB1.74KB
mobile (index.js)1.50KB0.62KB
mobile (offlineQueue.js)3.91KB1.35KB
mobile (pwa.js)0.97KB0.49KB
mobile (serviceWorker.js)1.48KB0.62KB
mobile (serviceWorkerSource.js)3.41KB1.48KB
mobile (useBreakpoint.js)1.54KB0.65KB
mobile (useGesture.js)6.96KB1.98KB
mobile (useOfflineSync.js)1.99KB0.72KB
mobile (usePullToRefresh.js)2.53KB0.85KB
mobile (useResponsive.js)0.71KB0.42KB
mobile (useResponsiveConfig.js)1.36KB0.63KB
mobile (useSpecGesture.js)4.32KB1.64KB
mobile (useTouchTarget.js)1.01KB0.54KB
permissions (MePermissionsProvider.js)8.75KB3.06KB
permissions (PermissionContext.js)0.31KB0.25KB
permissions (PermissionGuard.js)0.89KB0.45KB
permissions (PermissionProvider.js)3.67KB1.12KB
permissions (evaluator.js)4.41KB1.44KB
permissions (index.js)0.91KB0.41KB
permissions (store.js)0.91KB0.42KB
permissions (useFieldPermissions.js)1.28KB0.52KB
permissions (usePermissions.js)1.55KB0.71KB
plugin-ai (index.js)15.71KB3.79KB
plugin-calendar (index.js)45.23KB12.45KB
plugin-charts (index.js)61.49KB17.48KB
plugin-chatbot (index.js)180.33KB42.79KB
plugin-dashboard (index.js)118.67KB30.69KB
plugin-designer (index.js)210.51KB42.51KB
plugin-detail (index.js)237.80KB59.48KB
plugin-editor (index.js)2.46KB1.10KB
plugin-form (index.js)112.86KB27.24KB
plugin-gantt (index.js)162.79KB39.67KB
plugin-grid (index.js)187.97KB49.79KB
plugin-kanban (index.js)48.53KB13.38KB
plugin-list (index.js)109.73KB26.55KB
plugin-map (index.js)17.00KB5.32KB
plugin-markdown (index.js)13.72KB4.69KB
plugin-report (index.js)40.58KB10.58KB
plugin-timeline (index.js)25.99KB7.42KB
plugin-tree (index.js)8.50KB2.88KB
plugin-view (index.js)84.03KB20.55KB
providers (DataSourceProvider.js)0.75KB0.39KB
providers (MetadataProvider.js)1.37KB0.59KB
providers (ThemeProvider.js)1.90KB0.85KB
providers (UploadProvider.js)11.71KB3.53KB
providers (index.js)0.44KB0.22KB
providers (types.js)0.01KB0.04KB
react-runtime (index.js)5.67KB2.37KB
react (LazyPluginLoader.js)3.77KB1.33KB
react (SchemaRenderer.js)23.71KB7.95KB
react (data-invalidation.js)5.05KB2.08KB
react (index.js)1.23KB0.66KB
react (spec-input.js)0.20KB0.18KB
sdui-parser (codegen.js)4.09KB1.74KB
sdui-parser (index.js)4.47KB2.03KB
sdui-parser (parse.js)10.04KB2.82KB
sdui-parser (types.js)0.29KB0.24KB
sdui-parser (validate.js)4.69KB1.48KB
types (ai.js)0.20KB0.17KB
types (api-types.js)0.20KB0.18KB
types (app.js)2.87KB0.99KB
types (base.js)0.20KB0.18KB
types (blocks.js)0.20KB0.18KB
types (complex.js)0.20KB0.18KB
types (crud.js)0.20KB0.18KB
types (data-display.js)0.20KB0.18KB
types (data-protocol.js)0.20KB0.19KB
types (data.js)0.20KB0.18KB
types (designer.js)1.87KB0.85KB
types (disclosure.js)0.20KB0.18KB
types (error-code.js)1.54KB0.88KB
types (feedback.js)0.20KB0.18KB
types (field-types.js)0.20KB0.18KB
types (form.js)0.20KB0.18KB
types (http-retry.js)4.32KB2.02KB
types (index.js)2.71KB1.34KB
types (layout.js)0.20KB0.18KB
types (managed-by.js)0.19KB0.18KB
types (mobile.js)2.59KB1.31KB
types (navigation.js)0.20KB0.18KB
types (objectql.js)0.20KB0.18KB
types (overlay.js)0.20KB0.18KB
types (permissions.js)0.20KB0.18KB
types (plugin-scope.js)0.20KB0.18KB
types (record-components.js)0.20KB0.19KB
types (record-semantics.js)1.28KB0.67KB
types (registry.js)0.20KB0.18KB
types (reports.js)0.20KB0.18KB
types (spec-report.js)5.05KB1.93KB
types (system-fields.js)3.33KB1.54KB
types (theme.js)0.20KB0.18KB
types (ui-action.js)3.40KB1.71KB
types (views.js)0.20KB0.18KB
types (widget.js)0.20KB0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@yinlianghuiClaude

Copy link
Copy Markdown
CollaboratorAuthor

PM 验收(session_01GTRjn8xBqp75dk7kFupVRt):通过,转 ready 并挂 auto-merge。objectstack#7139 落地 —— 模块作用域遗留 console.log 删除 + 防回潮钉。

核验记录(head 1b97fcd97,基 f3b2874e1,实物核验 + CI 亲读):

  1. 实物精确:index.tsx 净 -1 行(仅删那一句),同文件 objectstack#7121 刚落的 dataSource 绑定零触碰;行号漂移(24→64,#7121 插入所致)已核实并记录,前提成立;「全仓孤例」断言重验为真(plugin-editor 的命中是示例字符串非可执行语句)。
  2. 钉子取舍正当:只 spy log/info/debug 三个噪音通道 —— Registry 的 console.warn 是设计内诊断契约(Registry.ts:162-205),一刀切「零输出」会把它钉死在 plugin-map,将来因无关原因翻红;vi.resetModules() + registry 非空断言双保险,杜绝模块缓存空跑假绿。这是「勉强的钉不如不钉」判断的反面好例:钉且钉得有边界。
  3. 反向验证:未删行的树上钉子红并原样抓到 payload(console.log(["Registering object-map..."])),且非空断言先过(证明模块体确实执行);删后转绿。
  4. 门与规程:plugin-map 4 文件 11 测试绿;type-check 78/78;控制字节门 + 自扫;changeset patch;fable 0;releases 零触碰;worktree 已清理。
  5. CI 亲读终态:20/20 completed、0 失败(Test shard×4 至 23:23:04Z;coverage/dependabot skipped 为 path-filter)。

out-of-scope objectstack#7146(eslint 未开 no-console,拦网缺失类 finding,自评「当前仓库干净」诚实)由 PM 分诊轮处理。


Generated by Claude Code

@yinlianghui
yinlianghui marked this pull request as ready for review August 10, 2026 00:08
@yinlianghui
yinlianghui added this pull request to the merge queueAug 10, 2026
Merged via the queue into main with commit 9ad21b6Aug 10, 2026
21 checks passed
@yinlianghui
yinlianghui deleted the claude/issue-7139-plugin-map-console-log branch August 10, 2026 00:08
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-map 在模块作用域 console.log('Registering object-map...'):每次加载该 plugin 都往控制台打一行

2 participants

@yinlianghui@claude