Repository navigation
[Bug] dsh-app-boot 0.2.1-rc.2:Profile 包里 require("punycode/") 导致导入崩溃(resolve.paths 返回 null) #10387
flizzywine
started this conversation in
General
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
现象
DSH 0.2.1-rc.2 下,通过
dsh plugin add装进 Profile 的包,只要依赖链里有require("pkg/")这种带末尾斜杠的写法、且pkg恰好是 Node 内置模块名,导入就会失败:实际触发者是 jsdom → whatwg-url → tr46:tr46(5.x 到最新的 7.0.0)都写的是
require("punycode/"),用末尾斜杠指定 npm 上的 punycode 包,而不是已弃用的内置模块。任何依赖 jsdom 的插件都会中招。原因
routeScoped里:barePackageName会排除isBuiltin(request),但isBuiltin("punycode/")为 false,于是放行;去掉斜杠后的name是内置名punycode,Node 对内置名的resolve.paths()返回null,for…of随即抛错。复现
npm install --global "@deepseek-ai/dsh@0.2.1-rc.2" pnpm dsh plugin --profile tavern add @deepseek-ai/dsh-web-app github:flizzywine/dsh-tavern dsh --profile tavern --no-open(macOS 与 Linux 容器均可复现;Node 22/24 都一样。)
修复建议
查找路径时保留斜杠,即改成
createRequire(parent).resolve.paths(name + "/")。对普通包名结果不变,对与内置模块同名的包则返回正常的 node_modules 查找路径。同文件第 1371、1681 行有同样的resolve.paths(name)调用,建议一并处理。本地按上面改动 dsh-app-boot 后,插件可以正常导入并启动。
相关:flizzywine/dsh-tavern#300
All reactions