fix(exports): 导出 ./package.json,修复打包宿主上客户端半区被静默跳过 - #2
Merged
Merged
Conversation
`@deepseek-ai/dsh-client-modules` 的宿主半区在 `locatePkgJson()` 里定位 loader
条目的包清单。Loader 未提供内部 `resolveSync` 时(DSH Desktop 这类打包宿主走的就是
这条回退分支)它调用:
createRequire(baseUrl).resolve('<pkg>/package.json')
本包的 `exports` 只导出 `.` 与 `./client`,该解析抛
`ERR_PACKAGE_PATH_NOT_EXPORTED` → `locatePkgJson` 返回 `undefined` →
`resolveMeta()` 返回 `null` → `processOne()` 把这行当作「未声明 dsh.client」
**静默跳过**(不抛错、不告警)。后果:
- 宿主半区照常激活(`inject = ['webServer']` 满足),启动审计
`assertEntriesActivated` 也通过,宿主日志无任何相关记录;
- `/plugins/?id=dsh-ide-git&rev=…` 返回 404,客户端半区从未下发,
浏览器控制台一片干净;
- better-sidebar 的 `+` 新建标签页与原生右侧栏 Guide 页都看不到入口。
对照同 profile 的其它插件:`dsh-scratchpad`、`dsh-better-sidebar` 的 `exports`
都带有 `"./package.json": "./package.json"`,所以不受影响。
复现(用 DSH 自带的组合器真实代码跑 `resolveMeta`,`ctx.loader.internal` 为
undefined 即回退分支):
no-internal | dsh-ide-git => NULL (silently skipped)
no-internal | dsh-scratchpad => OK
no-internal | dsh-better-sidebar => OK
补上该导出后两条件码路径均正常,`clientPath` 解析到 `src/client.js`。
环境:DSH 0.1.5-rc.2(DSH Desktop 2.0.13,Windows 11)、宿主 Node v24.18.1、
dsh-ide-git 0.5.5、npm 安装。
Refs: KannaKuron#1
Owner
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.
问题
从 npm 安装(
dsh plugin --profile <name> add dsh-ide-git)后,插件在 DSH Desktop 这类打包宿主上完全不出现:+新建标签页列表里没有 Git 条目;/dsh-ide-git/api/*路由存在(打到信任围栏,403 而非 404)→ 宿主半区是活的。即:宿主半区加载成功,客户端半区从未到达浏览器。详见 #1。
根因
@deepseek-ai/dsh-client-modules的宿主半区在locatePkgJson()里定位 loader 条目的包清单。Loader 未提供内部resolveSync时(打包宿主走的回退分支):本包
exports只导出.与./client,该解析抛ERR_PACKAGE_PATH_NOT_EXPORTED→locatePkgJson返回undefined→resolveMeta()返回null→processOne()把这行当作「未声明dsh.client」静默跳过(不抛错、不告警)。修复
"exports": { ".": "./src/index.js", - "./client": "./src/client.js" + "./client": "./src/client.js", + "./package.json": "./package.json" },验证
用 DSH 自带的
@deepseek-ai/dsh-client-modules真实代码跑resolveMeta(),ctx.loader.internal为undefined即上述回退分支:对照同 profile 的其它插件——它们的
exports都带"./package.json": "./package.json",所以不受影响:exports键dsh-ide-git.,./client← 缺dsh-scratchpad.,./client,./cordis.patch.yml,./package.jsondsh-better-sidebar.,./invariant,./client,./client/service,./client/api,./src/*,./package.json真机确认:补上该行后用
link:安装,fetch('/plugins/?id=dsh-ide-git&rev=…')不再 404,面板正常出现在侧边栏。环境:DSH 0.1.5-rc.2(DSH Desktop 2.0.13,Windows 11)、宿主 Node v24.18.1、dsh-ide-git 0.5.5、npm 安装。
建议(可选,不在本 PR 内)
现有三层测试都不过 DSH 的真实组合器,所以这个缺陷一路绿灯。可在
tests/smoke.mjs补一条解析门:未改
CHANGELOG.md按仓库「变更记录纪律」,条目随版本提交,留给维护者发版时补,以免与
npm version流程冲突。需要我加的话说一声。