Skip to content

fix: 8 个插件的客户端产物缺 loader 打包(web profile 起不来的根因线) #174

Closed

Description

@FeatherHunter

Question

8 个插件的客户端产物是裸 ESM(packages/plugin-*/dist/client.js 里是 tsc 直出的 import/export),而 DSH 把所有插件客户端拼成一条 <script> 加载——普通脚本先整体解析,一处语法错即整条不执行,于是所有插件的模块都注册不上,页面显示 Failed to load plugins(报错点名的包只是"第一个没注册上的",不是肇事者)。

dsh-bill-ilife 已经在本仓修好(commit f381ddd,见 #150 复盘评论)。本票收其余那几个包,并让仓库自己的门转绿。

现场证据(本席已复核,可复现)

  • 肇事链:packages/plugin-bill-ilife/dist/client.js 837 字节裸 ESM → 被 link 进 web profile → 组合包(实测 16,391,605 字节/64 模块)解析期即死 → 全插件注册数 0。
  • 他人第一手诊断(本仓外,只读):D:\dsh-plugin\dsh-mattpocock-skills-deck\docs\reviews\602-bill-client-bundle-format-handoff.html(含组合包原始字节、A/B 对照、真页面探针);其结论本席独立复核后认可。
  • 本仓自带门 test/client-bundle-48.test.mjs 就是这条契约(文件头:「served client.js 必须满足 DSH 真实 loader 契约」),当前 chef/home-ilife/schedule-ilife 各 3 例仍红。

受影响清单(按「有没有 __ModuleLoader__ 包装」判定)

包 dist/client.js 状态
plugin-bill-ilife 2.7 KB(loader 工厂包) ✅ 已修(f381ddd)
plugin-calorie/plugin-memo-ilife/plugin-manager 有包装 ✅ 本来就对(可作模板)
plugin-chef/plugin-home-ilife/plugin-schedule-ilife ~831 字节裸 ESM ⛔ 门里红,未装进任何 profile
plugin-home/plugin-memo/plugin-schedule(非 -ilife 那几个) ~831 字节裸 ESM ⛔ 同样缺打包(门未覆盖,建议一并核)

修法(照 plugin-calorie,每包四步)

  1. 新增 tsdown.config.ts(与 packages/plugin-calorie/tsdown.config.ts 同形:browser/CJS、window.__ModuleLoader__.load({id, factory}) 的 banner/footer、externals 白名单、codeSplitting:false),只改 PLUGIN_ID 与 entry;
  2. 新增 tsconfig.client.json(composite:false、noEmit:true,include 列该包客户端相关文件);
  3. package.json:build 改 build:host && build:client,加 build:client: tsdown、typecheck,devDependency [email protected];
  4. 宿主入口不得再导出 ./client.js 的值(export { X } from './client.js' 会让插件树启动期抛「does not provide an export named …」——客户端产物是 CJS 工厂包);客户端入口需导出 loader 契约的 inject(数组)与 apply(函数)。

验收

  • node --test test/client-bundle-48.test.mjs 全绿(当前 12 pass/9 fail);
  • 每包产物头部=window.__ModuleLoader__.load({ id: "<包名>", … }),物化后 typeof apply === 'function';
  • 装进任一 profile 后 dsh --profile <名> --port <空闲端口> --no-open 能正常起服务(本次用它做过 before/after 对照);
  • 全仓 node --test 失败集相应下降(本席修 bill 后 14 → 11,其中 9 例就是本票要清的)。

Notes

  • 纪律教训(写进票面):装任何插件进 profile 之前,先跑 test/client-bundle-48.test.mjs——它是这条契约的门;「预存失败」不等于"与本次无关",动了对应面就要复跑。
  • 本票只做「格式与契约」,不碰面板行为(面板 parity 属 bill复制样板线(桥+面板+双路证据) #59)。

Activity

  1. added
    bug
    on Sep 11, 2026
  2. FeatherHunter commented on Sep 16, 2026

    @FeatherHunter
    OwnerAuthor

    结论:已完成,关闭

    验收逐条对照(基线 0e093e4c,MAP #638 第二轮,零代码改动——修法改动早已在 HEAD,提交 61bb6631/f381ddd9 等):

    1. node --test test/client-bundle-48.test.mjs 全绿:持锁实跑 tests 21 / pass 21 / fail 0(票面时代为 12 pass/9 fail)。
    2. 每包产物头部=window.__ModuleLoader__.load({ id, factory }):7 个 web client 包逐包通过“classic 执行并注册自身 id”(裸 ESM 在 classic 语义下直接 SyntaxError,不可能绿)+“产物无 ESM 语法”两条门。
    3. profile 真机起服:未在本轮重做。依据——该对照在 bill 同模板前例(f381ddd)已做过 before/after;其余 6 包与 calorie 模板同形(banner/footer/externals/codeSplitting:false,上一轮 HEAD 口径已验),且本门即票面 Notes 指定的“这条契约的门”。此条记为前例覆盖,不另起服碰用户 profile。
    4. 全仓失败集:本门失败集由 9 例降至 0。

    机器读数:GATE-RUN runId=711d835b-6102-4772-ab9b-f2156c2963f0 cmd=node --test test/client-bundle-48.test.mjs waitedMs=40003 exit=0(ticket=174,日志 .scratch/map638/t174-gate.log,未入仓)。

    调查方式:MAP #638 分流调查+挑战席复核(上一轮初判可关→被推翻→本轮持锁复跑门转绿)+关票人复核。另:票面第二 ⛔ 行点名的非 -ilife 三包在基线中不存在(上一轮已验),门覆盖包零缺口。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions