chore: derive the workspace layout from pnpm-workspace.yaml only#3752
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
7f4c7eb to
2583388
Compare
cixzhang
left a comment
There was a problem hiding this comment.
🟡 Maintainer judgment recommended — the change itself looks clean, but the branch has a merge conflict with main and can't be merged as-is.
Initial review pass (community contributor).
Blocking (mechanical): rebase needed. main has moved under this branch — both package.json and apps/docsite/scripts/generate-data.mjs were changed upstream after the branch point, and the PR reports CONFLICTING. Please rebase on latest origin/main and re-push; the review can't clear a branch that won't merge.
On the change itself (looks good): consolidating the four copied workspace-walking loops into scripts/lib/workspace-globs.mjs and dropping the redundant root package.json workspaces array is a solid cleanup. Two things I verified:
- The line-based
packages:parser correctly scopes to that block, fixing the prior regex that over-matched entries fromminimumReleaseAgeExclude/overrides/allowBuilds. - The
throw-on-empty guard inreadWorkspaceGlobscloses the silent-empty failure mode ingenerate-data.mjs. - Remaining
pkg.workspacesreaders (packages/cli/src/utils/paths.mjs,scripts/verify-exports.mjs) are unaffected —findProjectRoothas no callers andverify-exportswalkspackages/directly.
Please confirm the post-rebase verification still holds (discoverPackageDirs() → same 13 dirs; docsite generate-data byte-identical summary) since the conflict is in exactly those two files.
Recap — #3752 · chore: derive the workspace layout from pnpm-workspace.yaml only · @Han5991
What it does: makes pnpm-workspace.yaml the single source of truth for the workspace layout, extracting the shared glob-walk into one helper and removing the duplicated workspaces array.
Recommendation: Rebase on main to resolve the conflict, then re-review. No objections to the change on its merits.
Four scripts already walked the `packages:` globs in pnpm-workspace.yaml,
each with its own copy of the same loop — setup-trusted-publishing.mjs even
apologizes for it ("Ported from check-changesets.mjs, which is NOT exported,
so it is copied here"). apps/docsite/scripts/generate-data.mjs was the lone
holdout, reading the root package.json `workspaces` array instead.
Extract the shared walk into scripts/lib/workspace-globs.mjs, point all five
at it, and drop the now-unused `workspaces` array from the root package.json.
Fixes a latent bug in the copied regex. `/^\s*-\s*["']?([^"'\n]+)["']?/gm`
swept the whole file, not just the `packages:` block, so it also picked up
`minimumReleaseAgeExclude`'s `@astryxdesign/*` — five globs where the file
declares four. It was harmless only because `@astryxdesign/` is not a real
directory and got skipped by a downstream existsSync. Any future list item
that happens to name one would have been walked as a workspace root. The
replacement is line-based and scoped to the `packages:` block.
generate-data.mjs also lost its silent-empty failure mode. `rootPkg.workspaces
|| []` meant a missing array produced an empty registry, no exception, and a
docsite build that shipped zero components. readWorkspaceGlobs() throws.
Verified:
- discoverPackageDirs() returns the same 13 directories before and after.
- `node apps/docsite/scripts/generate-data.mjs` prints a byte-identical
summary on this branch and on main (8 packages, 219 components, 582
blocks, 40 templates, 18 doc topics, 3 blog posts, 6 themes).
- check-changesets, format-changelogs --check, check-package-boundaries,
and format-changelogs.test.mjs (8 tests) all pass.
- `pnpm install --frozen-lockfile` still resolves all 26 workspace projects,
and @manypkg (what changesets uses) still reports tool=pnpm with 25
packages, so removing the array does not affect the release tooling.
2583388 to
666efaf
Compare
|
Rebased on latest The conflict was semantic, not just textual: #3858 landed
Post-rebase verification (as requested):
|
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
What
pnpm-workspace.yamlbecomes the single source of truth for the workspace layout, and the rootpackage.jsondrops itsworkspacesarray.Four scripts already walked the
packages:globs inpnpm-workspace.yaml, each carrying its own copy of the same loop.scripts/npm/setup-trusted-publishing.mjseven apologizes for it in a comment:apps/docsite/scripts/generate-data.mjswas the lone holdout, reading the rootpackage.jsonworkspacesarray instead — and it was the only remaining reason that array existed. (packages/cli/src/utils/paths.mjsalso readspkg.workspaces, butfindProjectRoot()has no callers anywhere in the repo and its tests build their own fixtures.)This extracts the shared walk into
scripts/lib/workspace-globs.mjs, points all five files at it, and deletes the array.Two bugs fixed on the way
The copied regex was over-matching.
/^\s*-\s*["']?([^"'\n]+)["']?/gmswept the entire YAML file rather than thepackages:block, so it also picked upminimumReleaseAgeExclude's entry:Five globs where the file declares four. Harmless only because
@astryxdesign/is not a real directory, so a downstreamexistsSyncskipped it. Any future list item underoverrides:orallowBuilds:that happened to name a real directory would have been walked as a workspace root. The replacement parse is line-based and scoped to thepackages:block.generate-data.mjshad a silent-empty failure mode.rootPkg.workspaces || []meant a missing array yielded an empty package list, no exception, and a docsite build that shipped zero components.readWorkspaceGlobs()throws instead.Verification
discoverPackageDirs()returns the same 13 directories before and after.node apps/docsite/scripts/generate-data.mjsprints a byte-identical summary on this branch and onmain: 8 packages, 219 components, 582 blocks (167 showcases, 448 examples), 40 templates, 18 doc topics, 3 blog posts, 6 themes.check-changesets,format-changelogs --check,check-package-boundaries, andformat-changelogs.test.mjs(8 tests) all pass.pnpm install --frozen-lockfilestill resolves all 26 workspace projects.@manypkg/get-packages— what changesets uses to enumerate the workspace — still reportstool: pnpmwith 25 packages, so removing the array does not affect release tooling.pnpm-workspace.yamlwith nopackages:block throws instead of returning[].Note
scripts/is outside the eslint ignore boundary, so these files get no lint coverage — the unused-import check after the refactor was done by hand.