[dsh-v0.1.5-alpha.1] packages/client/tsdown.client.ts 中 REPOSITORY_ROOT 路径深度错误,构建报 "no packages/*/*/package.json declares the name ..."
#5989
Unanswered
lijinxiao1982
asked this question in
Q&A
Replies: 0 comments
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.
Summary
packages/client/tsdown.client.ts:80computesREPOSITORY_ROOTwithnew URL("../..", import.meta.url), butimport.meta.urlat runtime resolves to each child package'stsdown.config.ts(e.g.packages/api/remotes/tsdown.config.ts), so../..lands atpackages/instead of the repository root.workspaceManifest()then scans the wrong directory and reports every workspace package as "undeclared".Reproduction
pnpm install pnpm add -Dw unrun # workaround for the unrelated missing-dep issue, see #5988 pnpm run buildActual
Root cause
packages/client/tsdown.client.ts:80:import.meta.urlat runtime points to the consumer ofclientBundle(each workspace package's owntsdown.config.ts), not topackages/client/tsdown.client.tsitself. So:import.meta.url../..resolves to…/packages/api/remotes/tsdown.config.ts…/packages/(wrong)…/packages/client/tsdown.client.ts(the file)…/packages/(also wrong for the file itself)The intended resolution is the repository root, which requires three
..segments from anypackages/<group>/<pkg>/location:Verified locally with a debug
console.error:After changing
"../.."→"../../..":Suggested fix
Patch the path depth in
packages/client/tsdown.client.ts:80:A defensive alternative is to derive the root from
process.cwd()(which tsdown sets to the repo root for workspace builds) instead ofimport.meta.url, e.g.:That avoids future drift if the file is moved again.
All reactions