Skip to content

fix(workspace): keep generated versions/* out of the root pnpm workspace - #333

Merged
pyramation merged 1 commit into
mainfrom
fix/generated-versions-workspace
Aug 1, 2026
Merged

fix(workspace): keep generated versions/* out of the root pnpm workspace#333
pyramation merged 1 commit into
mainfrom
fix/generated-versions-workspace

Conversation

@pyramation

Copy link
Copy Markdown
Collaborator

Summary

pnpm-lock.yaml ping-pongs forever, and pnpm install --frozen-lockfile fails locally:

ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml
is not up to date with <ROOT>/packages/deparser/versions/13/package.json

packages/{parser,deparser}/versions/* are generated by prepare-versions and gitignored
(packages/parser/.gitignore, packages/deparser/.gitignore) — but the root workspace globbed them:

packages:
  - 'packages/*'
  - 'packages/deparser/versions/*'   # generated + gitignored
  - 'packages/parser/versions/*'     # generated + gitignored

So workspace membership depended on whether a given machine had happened to run the generator.
A machine that had adds those importers on every install; CI's clean checkout never has the dirs
and prunes them straight back out. The diff comes back no matter which side you commit, and
git reset --hard doesn't help — gitignored dirs survive it, so the stale membership persists.

Fix is to make membership deterministic rather than incidental: drop the two globs, and have both
generators emit a pnpm-workspace.yaml into versions/ so the generated tree is a self-contained
workspace with its own (gitignored) lockfile.

 // packages/parser/scripts/prepare-versions.ts
 // packages/deparser/scripts/generate-version-packages.ts
+fs.writeFileSync(path.join(versionsDir, 'pnpm-workspace.yaml'), "packages:\n  - '*'\n");

Release flow gains one step, documented in PUBLISH.md:

npm run prepare-versions
(cd versions && pnpm install)   # once per generation, covers every version dir

The lockfile shrinks by ~2900 lines net: the last release commit had committed the versions/*
importers, which dragged in every old libpg-query / pgsql-deparser / @pgsql/types referenced
by PG 13–18 sub-packages. Removing the importers removes them too. That diff is the point of the
PR, not collateral.

Verification

  • pnpm install --frozen-lockfile at the root — passes with the generated dirs present on disk,
    which is the case that used to fail
  • pnpm install with the dirs present — leaves pnpm-lock.yaml untouched (the churn is gone)
  • pnpm build — all 15 packages pass
  • cd packages/parser/versions && pnpm install && cd 13 && npm run build — the generated tree
    still builds standalone, producing dist/{index.js,index.d.ts,esm/}

Note for anyone with an existing checkout

Generated dirs from before this change have no nested pnpm-workspace.yaml. Re-run
npm run prepare-versions (or just delete packages/{parser,deparser}/versions) to pick it up.

Link to Devin session: https://app.devin.ai/sessions/2aa454e560904773a0a6955712e0aeda
Requested by: @pyramation

packages/{parser,deparser}/versions/* are generated by prepare-versions and
gitignored, but the root pnpm-workspace.yaml globbed them. Workspace membership
therefore depended on whether a machine had run the generator: every install on
a machine that had would add their importers to pnpm-lock.yaml, and every clean
checkout would prune them back out, so the lockfile ping-ponged forever and
--frozen-lockfile failed locally.

Drop the two globs and have both generators emit a pnpm-workspace.yaml into
versions/, making each generated tree a self-contained workspace with its own
gitignored lockfile. Release flow gains one 'pnpm install' inside versions/.

Also drops the versions/* importers the last release commit added, and with them
every old libpg-query / pgsql-deparser / @pgsql/types they dragged in.
@pyramation pyramation self-assigned this Aug 1, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit 4d050f4 into main Aug 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant